Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7556625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:54:22+00:00 2026-05-30T11:54:22+00:00

I’m trying to get Deleporter to do some cross process integration testing. The tests

  • 0

I’m trying to get Deleporter to do some cross process integration testing. The tests are being run using WatiN against our ASP.NET MVC3 application. We use Autofac for dependency injection.

I’ve looked at Steve Sanderson’s blog about setting it up to return a mock repository using NInject.

// Inject a mock IDateProvider, setting the clock back to 1975
var dateToSimulate = new DateTime(1975, 1, 1);
Deleporter.Run(() => {
    var mockDateProvider = new Mock<idateProvider>();
    mockDateProvider.Setup(x => x.CurrentDate).Returns(dateToSimulate);
    NinjectControllerFactoryUtils.TemporarilyReplaceBinding(mockDateProvider.Object);
});

Is there an Autofac equivalent of TemporarilyReplaceBinding?

I’ve tried the following below but get an error of “The request lifetime scope cannot be created because the HttpContext is not available.”

The table is being passed by SpecFlow.

        var tableSerialized = new SerializableTable(table);

        Deleporter.Run(() =>
        {
            var mockRepository = new Mock<IRepository<SmsMessageReceived>>();
            mockRepository.Setup(x => x.Table)
                .Returns((from row in tableSerialized.Rows
                          select new SmsMessageReceived
                          {
                              DateCreated = DateTime.Now,
                              Id = Int32.Parse(row[ColumnId]),
                              MessageBody = row[ColumnMessageBody]
                          }).AsQueryable() as IQueryable<SmsMessageReceived>);

            var builder = new ContainerBuilder();
            builder.RegisterInstance(mockRepository.Object);
            var container = builder.Build();
            builder.Update(container);
        });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:54:24+00:00Added an answer on May 30, 2026 at 11:54 am

    This was an error on my part. In the code above I missed out how I was obtaining the container to be updated. I was doing this through a call to

    DependencyResolver.Current.GetService()

    this was what was throwing the error about HttpContext not available.

    I stripped this out and then in my Global.asax.cs I added a static instance to hold the built up IContainer. So changing the code that Deleporter runs to

            Deleporter.Run(() =>
            {
                var mockRepository = new Mock<IRepository<SmsMessageReceived>>();
                mockRepository.Setup(x => x.Table)
                    .Returns((from row in tableSerialized.Rows
                              select new SmsMessageReceived
                              {
                                  DateCreated = DateTime.Now,
                                  Id = Int32.Parse(row[ColumnId]),
                                  MessageBody = row[ColumnMessageBody]
                              }).AsQueryable() as IQueryable<SmsMessageReceived>);
                var builder = new ContainerBuilder();
                builder.RegisterInstance(mockRepository.Object);
                builder.Update(MvcApplication.Container);
            });
    

    MvcApplication is the class in Global.asax.cs.

    Then added a reference to Moq to my web project and now it works perfectly.

    I do wonder whether there’s a better way to get the container than a static, but this does work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.