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 3343580
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:58:16+00:00 2026-05-18T00:58:16+00:00

We have an MVC web which is running in Autofac. All the config is

  • 0

We have an MVC web which is running in Autofac. All the config is stored in an autofac config section in the web.config and when run the Global asax sets up the container and sorts out all the modules by providing them with their config settings – the one I’m interested in at the moment is the NHibernate module – so this gets the connection string set into its constructor.

I want to build some tests to test Data Access with NHibernate – we’ve got repositories and a service layer but this isn’t necessarily relevant.

Should I be adding an extra project to the Solution with all my tests in and if I do this do I need to replicate the database connection string in an autofac config for this test project and build a test container in this project which will test my data access? Or should I be trying to get hold of the web app’s container to do the testing with – I assume not as the Global.asax’s Application_start will not run unless hit by an http GET. I don’t really want to replicate all the config and container creation of the web app but at the moment I’m thinking I will have to…?

  • 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-18T00:58:17+00:00Added an answer on May 18, 2026 at 12:58 am

    Sorry to see the slow response to this. It isn’t all that common to write integration tests for the actual DAL – much of the time unit tests against a stubbed DAL are sufficient – so there’s probably not as much experience out there with this kind of scenario.

    If you put all of your configuration into Autofac Modules, your Global.asax content could be as simple as calling builder.RegisterModule(new ConfigurationSettingsReader()) – the same configuration file could then be loaded from your integration tests using the overload of ConfigurationSettingsReader() that takes a filename.

    Rather than have a separate module for NHibernate under test, consider using InstancePerLifetimeScope() instead of HttpRequestScoped()/InstancePerHttpRequest(). This has the same effect (unless you’ve tinkered with the lifetime hierarchy :)) and will work in both web and non-web scenarios.

    Hope this helps!
    Nick

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

Sidebar

Related Questions

I have an object which contains models for my ASP.NET MVC web app. The
I have an ASP.NET MVC web site. I have many actions which require authentication
I have a Clustered Windows Hosting site which currently hosts an MVC Web Application
I have a System.Web.Mvc.RazorView object which is strongly typed when in cshtml. Can I
I have an ASP.NET MVC web application running in IIS as a subweb; let's
I have ASP.NET MVC Beta on our web server running a few apps. My
I'm running a webapp in Spring Web MVC 3.0 and I have a number
I have an asp.net mvc 2 application which works fine when run from visual
I have an MVC web app running in azure that serves up large files
A colleague of mine replaced by mistake a web.config file which we don't have

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.