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

  • Home
  • SEARCH
  • 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 3615892
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:25:49+00:00 2026-05-18T22:25:49+00:00

I’m writing some unit tests for Fluent NHibernate mappings (for the first time). When

  • 0

I’m writing some unit tests for Fluent NHibernate mappings (for the first time). When run in visual studio they run perfectly fine.

This is using Resharpers Unit Test window or the built in Visual Studio one.

The problem is when the unit tests are run from MSTest:

mstest /testcontainer:Tests.MyProject.dll

The unit tests fail…

The only error I get from the trx file thats generated is:

BlockquoteUnit Test Adapter threw exception: Type is not resolved for member ‘FluentNHibernate.Cfg.FluentConfigurationException,FluentNHibernate, Version=1.2.0.694, Culture=neutral, PublicKeyToken=8aa435e3cb308880’..

Which doesn’t help… I can’t debug the code because it works perfectly fine in visual studio, and the error message in the test file doesn’t give me any information…

The code around creating the session is:

    public class InMemoryDatabaseTest : IDisposable
    {
        private Configuration _configuration;
        private ISessionFactory _sessionFactory;
        protected ISession _session;

        public InMemoryDatabaseTest(Assembly assemblyContainingMappedType)
        {
            if (_configuration == null)
                _sessionFactory = CreateSessionFactory(assemblyContainingMappedType);

            _session = _sessionFactory.OpenSession();

            new SchemaExport(_configuration).Execute(false, true, false, _session.Connection, Console.Out);
        }

        private ISessionFactory CreateSessionFactory(Assembly assemblyContainingMappedType)
        {
            return Fluently.Configure()
                .Database(SQLiteConfiguration.Standard.InMemory)
                .Mappings(m => m.FluentMappings.AddFromAssembly(assemblyContainingMappedType))
                .ExposeConfiguration(cfg => _configuration = cfg)
                .BuildSessionFactory();
        }

        public void Dispose()
        {
            _session.Dispose();
        }
    }

I’m not sure if this is the correct way of creating the session for unit testing tho.

Anyone got any idea what’s wrong 🙁

  • 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-18T22:25:49+00:00Added an answer on May 18, 2026 at 10:25 pm

    I solved this problem. Turns out it was a PEBKAC problem.

    For the test configuration I needed to add the System.Data.Sqlite assembly to the configuration so that it got copied to the TestResult folder prior to the test being run.

    So the FluentNHibernate Configuration exception was that the Sqlite assembly didn’t exist.

    Adding the assembly, the test ran in the console and now runs on the integration builds. YAY.

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

Sidebar

Related Questions

No related questions found

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.