views:

12

answers:

0

I have some NUnit integration tests to test my FluentNHibernate mappings using a SQLite in-memory database. I am using the ReSharper test runner (v5.0.1659.36) in Visual Studio 2008.

When one of the NHibernate tests fails, the ReSharper test runner and Visual Studio freezes for 30+ seconds. (It will show that it failed but not show the stack trace until the GUI is responsive again.) The NUnit test runner does not experience any delays with the same conditions. Does anyone know how to resolve this?

Thanks

Here's some code (C#):

public abstract class InMemoryDatabaseFixture {
    private SingleConnectionSessionSourceForSQLiteInMemoryTesting _sessionSource;
    protected ISession Session { get; private set; }

    [SetUp]
    public virtual void SetUp() {
        _sessionSource = new SingleConnectionSessionSourceForSQLiteInMemoryTesting(GetConfiguration());
        Session = _sessionSource.CreateSession();
        _sessionSource.BuildSchema(Session);
    }

    [TearDown]
    public virtual void TearDown() {
        if (Session == null) return;
        Session.Dispose();
        Session = null;
        _sessionSource.SessionFactory.Dispose();
        _sessionSource = null;
    }

    private static FluentConfiguration GetConfiguration() {
        return Fluently.Configure()
            .Database(SQLiteConfiguration.Standard.InMemory().ShowSql())
            .Mappings(m => m.FluentMappings.AddFromAssemblyOf<EmployeeMap>());
    }
}

[TestFixture]
public class EmployeeMappingsTest : InMemoryDatabaseFixture {
    [TestCase]
    public void Should_correctly_map_Employee() {
        new PersistenceSpecification<Employee>(Session)
            .CheckProperty(e => e.EmployeeNumber, "12345")
            .CheckProperty(e => e.Username, "jdoe")
            .VerifyTheMappings();
    }
}

public class EmployeeMap : ClassMap<Employee> {
    public EmployeeMap() {
        Table("Employee");
        Id(e => e.EmployeeNumber);
        Map(e => e.Username); // comment this line out to cause test to fail
    }
}

public class Employee {
    public virtual string EmployeeNumber { get; set; }
    public virtual string Username { get; set; }
}