public void Setup() { var cfg = new FluentConfiguration(); cfg.Audit <Dog>(); cfg.Audit <Cat>(); metas = cfg.CreateMetaData(null); }
public void Setup() { var fluent = new FluentConfiguration(); fluent.Audit <TestEntityWithContext>(); fluent.Audit <FactoryCreatedTestEntity>() .UseFactory(new TestEntityFactory()); metas = fluent.CreateMetaData(null); }
public void Setup() { var cfg = new FluentConfiguration(); cfg.Audit <FieldEntity>() .Exclude("data1") .Exclude("data2"); cfg.Audit <NotAuditedOwnerEntity>() .ExcludeRelationData("RelationField"); metas = cfg.CreateMetaData(null); }
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); }
protected override void Configure(NHibernate.Cfg.Configuration configuration) { // The ValidatorInitializer and the ValidateEventListener share the same engine // Initialize the SharedEngine fortest = new NHibernateSharedEngineProvider(); Cfg.Environment.SharedEngineProvider = fortest; ValidatorEngine ve = Cfg.Environment.SharedEngineProvider.GetEngine(); ve.Clear(); XmlConfiguration nhvc = new XmlConfiguration(); nhvc.Properties[Cfg.Environment.ApplyToDDL] = "true"; nhvc.Properties[Cfg.Environment.AutoregisterListeners] = "true"; nhvc.Properties[Cfg.Environment.ValidatorMode] = "UseAttribute"; nhvc.Properties[Cfg.Environment.MessageInterpolatorClass] = typeof(PrefixMessageInterpolator).AssemblyQualifiedName; var enversConf = new FluentConfiguration(); enversConf.Audit <Address>(); configuration.IntegrateWithEnvers(enversConf); ve.Configure(nhvc); ValidatorInitializer.Initialize(configuration); }
public void WhenRegisterInheritedThenBaseIsAudited() { var cfg = new FluentConfiguration(); cfg.Audit(new[] { typeof(Dog), typeof(Cat) }); cfg.CreateMetaData(null).Keys.Should().Have.SameValuesAs(new[] { typeof(Animal), typeof(Cat), typeof(Dog) }); }
public void WhenRegisterTypeThenIsAudited() { var cfg = new FluentConfiguration(); cfg.Audit(new[] { typeof(Animal) }); cfg.CreateMetaData(null).Keys.Should().Contain(typeof(Animal)).And.Have.Count.EqualTo(1); }
public void Setup() { var cfg = new FluentConfiguration(); cfg.Audit <NotAuditedOwnerEntity>() .ExcludeRelationData(s => s.Relation); metas = cfg.CreateMetaData(null); }
public void ExcludingMethodShouldThrow() { var cfg = new FluentConfiguration(); Assert.Throws <FluentException>(() => cfg.Audit <MethodEntity>() .Exclude(obj => obj.SomeMethod())); }
public void IncorrectString() { var cfg = new FluentConfiguration(); Assert.Throws <FluentException>(() => cfg.Audit(typeof(FieldEntity)) .Exclude("data3") ); }
public void Setup() { var cfg = new FluentConfiguration(); cfg.Audit <Dog>() .Exclude(dog => dog.Name) .Exclude("weight"); metas = cfg.CreateMetaData(null); }
public void Setup() { var cfg = new FluentConfiguration(); cfg.Audit <SomePropsEntity>() .Exclude(s => s.Number) .Exclude(s => s.String) .Exclude(s => s.FieldNumber); metas = cfg.CreateMetaData(null); }
public void WhenRegisterInheritedThenAllHasOnlyAuditedAttribute() { var cfg = new FluentConfiguration(); cfg.Audit(new[] { typeof(Dog), typeof(Cat) }); var metas = cfg.CreateMetaData(null); foreach (var entityMeta in metas.Values) { entityMeta.ClassMetas.OnlyContains <AuditedAttribute>(); } }
public void ShouldSetTableInfo() { var fluentCfg = new FluentConfiguration(); fluentCfg.Audit(typeof(StrTestEntity)) .SetTableInfo(table => { table.Schema = "testschema"; table.Catalog = "testcatalog"; table.Value = "tableName"; }); CheckTableInfo(fluentCfg); }
public void ShouldSetMapperGeneric() { var propInfo = typeof(SetRefCollEntity).GetProperty("Collection"); var fluentCfg = new FluentConfiguration(); fluentCfg.Audit <SetRefCollEntity>() .SetCollectionMapper <SomeCollectionMapper>(e => e.Collection); var metas = fluentCfg.CreateMetaData(null); var memberMetas = metas[typeof(SetRefCollEntity)].MemberMetas[propInfo]; memberMetas.OnlyContains <CustomCollectionMapperAttribute>(); memberMetas.OfType <CustomCollectionMapperAttribute>().First().CustomCollectionFactory .Should().Be.EqualTo <SomeCollectionMapper>(); }
public void ShouldSetJoinTableInfo() { var fluentCfg = new FluentConfiguration(); fluentCfg.Audit(typeof(SetRefCollEntity)) .SetTableInfo("Collection", table => { table.Schema = "testschema"; table.Catalog = "testcatalog"; table.TableName = "tableName"; table.InverseJoinColumns = new[] { "donald", "duck" }; }); CheckJoinTableInfo(fluentCfg); }
public void PropertyShouldHaveOneAuditAttributeWithNoAuditedRelation_using_field() { var cfg = new FluentConfiguration(); cfg.Audit <NotAuditedOwnerEntity>() .ExcludeRelationData("RelationField"); metas = cfg.CreateMetaData(null); var propInfo = typeof(NotAuditedOwnerEntity).GetField("RelationField"); var entMeta = metas[typeof(NotAuditedOwnerEntity)]; entMeta.MemberMetas[propInfo] .Should().Have.Count.EqualTo(1); var auditAttr = (AuditedAttribute)entMeta.MemberMetas[propInfo].First(); auditAttr.TargetAuditMode.Should().Be.EqualTo(RelationTargetAuditMode.NotAudited); }