Skip to content

Commit 3302718

Browse files
committed
now AutoPersistenceModel recognizes multiple mapping overrides when declared on the same type
1 parent ffa35ca commit 3302718

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/FluentNHibernate.Specs/Automapping/OverrideSpecs.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,52 @@ public class when_using_multiple_overrides_from_different_assemblies
7676
static AutoPersistenceModel model;
7777
static ClassMapping mapping;
7878
}
79+
80+
[Subject(typeof(IAutoMappingOverride<>))]
81+
public class when_multiple_overrides_present_in_one_class
82+
{
83+
Establish context = () =>
84+
{
85+
model = AutoMap.Source(new StubTypeSource(typeof(Entity), typeof(Parent), typeof(B_Parent)));
86+
model.Override(typeof(MultipleOverrides));
87+
};
88+
89+
Because of = () =>
90+
{
91+
entityMapping = model.BuildMappingFor<Entity>();
92+
parentMapping = model.BuildMappingFor<Parent>();
93+
bParentMapping = model.BuildMappingFor<B_Parent>();
94+
};
95+
96+
It should_apply_overrides_to_every_class_for_which_such_were_provided = () =>
97+
{
98+
entityMapping.EntityName.ShouldEqual("customEntityName");
99+
parentMapping.TableName.ShouldEqual("fancyTableName_Parent");
100+
bParentMapping.BatchSize.ShouldEqual(50);
101+
};
102+
103+
104+
static AutoPersistenceModel model;
105+
static ClassMapping entityMapping;
106+
static ClassMapping parentMapping;
107+
static ClassMapping bParentMapping;
108+
}
109+
110+
public class MultipleOverrides: IAutoMappingOverride<Entity>, IAutoMappingOverride<Parent>, IAutoMappingOverride<B_Parent>
111+
{
112+
public void Override(AutoMapping<Entity> mapping)
113+
{
114+
mapping.EntityName("customEntityName");
115+
}
116+
117+
public void Override(AutoMapping<Parent> mapping)
118+
{
119+
mapping.Table("fancyTableName_Parent");
120+
}
121+
122+
public void Override(AutoMapping<B_Parent> mapping)
123+
{
124+
mapping.BatchSize(50);
125+
}
126+
}
79127
}

0 commit comments

Comments
 (0)