public void WhenGetAuditConfMultipleTimesThenDoesNotThrowsForDupicatedMappings() { var cfg = new Cfg.Configuration(); cfg.Configure(); cfg.AddXml(SimpleMapping); AuditConfiguration.GetFor(cfg); //<< external call AuditConfiguration.SetConfigMetas(cfg, new AttributeConfiguration()); var listeners = new[] { new AuditEventListener() }; cfg.AppendListeners(ListenerType.PostInsert, listeners); cfg.AppendListeners(ListenerType.PostUpdate, listeners); cfg.AppendListeners(ListenerType.PostDelete, listeners); cfg.AppendListeners(ListenerType.PostCollectionRecreate, listeners); cfg.AppendListeners(ListenerType.PreCollectionRemove, listeners); cfg.AppendListeners(ListenerType.PreCollectionUpdate, listeners); Executing.This(() => { using (cfg.BuildSessionFactory()) { // build the session factory to run initialization of listeners and be completelly sure // there isn't problems } }).Should().NotThrow(); }
public void WhenIntegrateThenBuildSessionFactoryDoesNotThrows() { var cfg = new Cfg.Configuration(); cfg.Configure().OverrideSettingsFromEnvironmentVariables(); cfg.AddXml(SimpleMapping); cfg.IntegrateWithEnvers(); Executing.This(() => { using (cfg.BuildSessionFactory()) { // build the session factory to run initialization of listeners and be completelly sure // there isn't problems } }).Should().NotThrow(); }
public void BaseSetup() { TestAssembly = GetType().Assembly.GetName().Name; Cfg = new Cfg.Configuration().SetEnversProperty(ConfigurationKey.AuditStrategy, StrategyType); AddToConfiguration(Cfg); Cfg.Configure().OverrideSettingsFromEnvironmentVariables(); addMappings(); Cfg.IntegrateWithEnvers(new AuditEventListener(), EnversConfiguration()); createDb(); _sessionFactory = (ISessionFactoryImplementor)Cfg.BuildSessionFactory(); if (!testShouldRun()) { Assert.Ignore(TestShouldNotRunMessage()); } createDbSchema(); Session = openSession(_sessionFactory); Initialize(); closeSessionAndAuditReader(); Session = openSession(_sessionFactory); }
public void BaseSetup() { TestAssembly = GetType().Assembly.GetName().Name; Cfg = new Cfg.Configuration(); Cfg.SetEnversProperty(ConfigurationKey.AuditStrategy, StrategyType); AddToConfiguration(Cfg); Cfg.Configure(); addMappings(); Cfg.IntegrateWithEnvers(new AuditEventListener(), EnversConfiguration()); SessionFactory = Cfg.BuildSessionFactory(); var notRun = TestShouldNotRunMessage(); if (!string.IsNullOrEmpty(notRun)) { Assert.Ignore(notRun); } Session = openSession(SessionFactory); Initialize(); closeSessionAndAuditReader(); Session = openSession(SessionFactory); }
protected virtual void BuildSessionFactory() { sessions = cfg.BuildSessionFactory(); connectionProvider = ((ISessionFactoryImplementor)sessions).ConnectionProvider as DebugConnectionProvider; }
/// <summary> /// Rebuild the Session factory /// </summary> /// <remarks> /// in case you need to change the NHConfiguration on the fly /// </remarks> public void ReBuildSessionfactory() { sessionFactory = nHConfiguration.BuildSessionFactory(); }