public void TestThatNHInitializeAwareIsCalled() { var mock = new NHInitAwareMock { ConfiguredWasCalled = 0, InitializedWasCalled = 0 }; InitializeNHibernateAndIoC(ContainerFilePath, DatabaseEngine.SQLite, ":memory:", MappingInfo.From().SetNHInitializationAware(mock), _ => { }); Assert.AreEqual(1, mock.BeforeInitializationCalled); Assert.AreEqual(1, mock.ConfiguredWasCalled); Assert.AreEqual(1, mock.InitializedWasCalled); }
protected void VerifyCanCreateUnitOfWorkContextFor(string containerPath, DatabaseEngine databaseEngine, string databaseName) { int nextContextPosition = Contexts.Count; // create the UnitOfWorkContext // var mappingInfo = MappingInfo.From(typeof(GuidEntityForTesting).Assembly, typeof(FluentProduct).Assembly); InitializeNHibernateAndIoC(containerPath, databaseEngine, databaseName, mappingInfo, _ => { }); var context = Contexts[nextContextPosition]; Assert.IsNotNull(context); if (containerPath != null) { Assert.AreEqual(containerPath, context.ContainerConfigPath); } else { Assert.IsEmpty(context.ContainerConfigPath); } Assert.AreEqual(databaseEngine, context.DatabaseEngine); if (databaseName.IsWhiteSpace()) { Assert.AreEqual(NHibernateInitializer.DeriveDatabaseNameFrom(databaseEngine, mappingInfo.MappingAssemblies[0]), context.DatabaseName); } else { Assert.AreEqual(databaseName, context.DatabaseName); } Assert.AreEqual(CurrentContext, context, "Context just build has been assigned to CurrentContext"); }