public void ShouldUseDefaultValue()
        {
            var nhConfiguration = new Cfg.Configuration();

            nhConfiguration.IntegrateWithEnvers();
            AuditConfiguration.GetFor(nhConfiguration).GlobalCfg.StoreDataAtDelete
            .Should().Be.False();
        }
        public void CanBeSetByConfigurationKey()
        {
            var nhConfiguration = new Cfg.Configuration();

            nhConfiguration.SetEnversProperty(ConfigurationKey.StoreDataAtDelete, true);
            nhConfiguration.IntegrateWithEnvers();
            AuditConfiguration.GetFor(nhConfiguration).GlobalCfg.StoreDataAtDelete
            .Should().Be.True();
        }
        public void CanBeSetByConfigurationKeyMethod()
        {
            var nhConfiguration = new Cfg.Configuration();

            ConfigurationKey.StoreDataAtDelete.SetUserValue(nhConfiguration, true);
            nhConfiguration.IntegrateWithEnvers();
            AuditConfiguration.GetFor(nhConfiguration).GlobalCfg.StoreDataAtDelete
            .Should().Be.True();
        }
        public void ShouldThrowCorrectException()
        {
            var cfg = new Cfg.Configuration();

            cfg.Configure();
            cfg.AddResource("NHibernate.Envers.Tests.NetSpecific.UnitTests.Ids.Mapping.hbm.xml", GetType().Assembly);

            Assert.Throws <AuditException>(() => cfg.IntegrateWithEnvers());
        }
        public void CanBeSetNhCoreWay()
        {
            var nhConfiguration = new Cfg.Configuration();

            nhConfiguration.SetProperty("nhibernate.envers.store_data_at_delete", "true");
            nhConfiguration.IntegrateWithEnvers();
            AuditConfiguration.GetFor(nhConfiguration).GlobalCfg.StoreDataAtDelete
            .Should().Be.True();
        }
        public void WhenCallIntegrationThenMappingsShouldBeAvailableImmediately()
        {
            var cfg = new Cfg.Configuration();

            cfg.Configure();
            cfg.AddXml(SimpleMapping);
            cfg.IntegrateWithEnvers();

            cfg.ClassMappings.Where(cm => cm.EntityName.Contains("SimpleAuiditableForConfEntity")).Should().Have.Count.EqualTo(2);
        }
        public void ShouldResultInMappingException()
        {
            var nhCfg = new Cfg.Configuration();

            nhCfg.Configure()
            .AddResource("NHibernate.Envers.Tests.Integration.SuperClass.AuditOverride.Invalid.Mapping.hbm.xml", GetType().Assembly);

            Assert.Throws <MappingException>(() =>
                                             nhCfg.IntegrateWithEnvers());
        }
Exemplo n.º 8
0
        public void ShouldThrowMappingException()
        {
            var assembly      = GetType().Assembly;
            var assemblyName  = assembly.GetName().Name;
            var configuration = new Cfg.Configuration()
                                .Configure()
                                .AddResource(assemblyName + ".NetSpecific.Integration.Configuration.Incorrect.Mapping.hbm.xml", assembly);

            Assert.Throws <MappingException>(() => configuration.IntegrateWithEnvers());
        }
Exemplo n.º 9
0
        public void TestCustomLists()
        {
            var cfg = new Cfg.Configuration();

            cfg.Configure();
            cfg.AddResource("NHibernate.Envers.Tests.NetSpecific.UnitTests.CustomLists.Mapping.hbm.xml", GetType().Assembly);

            var ecfg = new FluentConfiguration();

            ecfg.Audit <AuditParent>().SetCollectionMapper <CustomCollectionMapperFactory <AuditChild> >(a => a.Children);
            ecfg.Audit <AuditChild>();

            // Throws exceptions without custon list hooks
            cfg.IntegrateWithEnvers(ecfg);
        }
Exemplo n.º 10
0
        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);
 }
Exemplo n.º 12
0
        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);
        }