public DrawerControllerTests() : base(new ApiTestSetup <ISession>( Startup.GetContainer(), WebApiConfig.Register, builder => { builder.RegisterType <LocalDb>().AsSelf(); // this needs to be registered so it's Disposed properly // changing the ISession to a singleton so that the two ISession Resolve() calls // produce the same instance such that the transaction includes all test activity. builder.Register(context => { var connString = context.Resolve <LocalDb>().OpenConnection().ConnectionString; // migrate empty db Program.Main(new[] { connString }); return(NhibernateConfig.CreateSessionFactory(connString).OpenSession()); }) .As <ISession>() .SingleInstance(); }, session => session.BeginTransaction(), session => session.Transaction.Dispose(), // tear down transaction to release locks session => { NhibernateConfig.CompleteRequest(session); session.Clear(); // this is to ensure we don't get ghost results from the NHibernate cache })) { }
public DeleteIcControllerTests() : base(new ApiTestSetup <ISession>( ContainerConfig.BuildContainer(), WebApiConfig.Register, builder => { // changing the ISession to a singleton so that the two ISession Resolve() calls // produce the same instance such that the transaction includes all test activity. builder.Register(context => NhibernateConfig.CreateSessionFactory().OpenSession()) .As <ISession>() .SingleInstance(); }, session => session.BeginTransaction(), session => session.Transaction.Dispose(), // tear down transaction to release locks session => { NhibernateConfig.CompleteRequest(session); session.Clear(); // this is to ensure we don't get ghost results from the NHibernate cache } )) { }