-
Notifications
You must be signed in to change notification settings - Fork 685
/
Copy pathPublicAutoMappingOverrideAlterationTests.cs
67 lines (55 loc) · 1.99 KB
/
PublicAutoMappingOverrideAlterationTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using FluentNHibernate.Automapping;
using FluentNHibernate.Automapping.Alterations;
using FluentNHibernate.Automapping.TestFixtures;
using FluentNHibernate.Testing.Automapping;
using FluentNHibernate.Testing.Fixtures.AutoMappingAlterations.Model;
using NUnit.Framework;
namespace FluentNHibernate.Testing.AutoMapping.Overrides
{
[TestFixture]
public class PublicAutoMappingOverrideAlterationTests
{
private AutoMappingOverrideAlteration alteration;
[SetUp]
public void CreateOverride()
{
alteration = new AutoMappingOverrideAlteration(typeof(ExampleClass).Assembly, false);
}
[Test]
public void OverridesApplied()
{
var model = AutoMap.AssemblyOf<Baz>()
.Where(t => t.Namespace == typeof(Baz).Namespace)
.Alterations(x => x.Add(alteration));
new AutoMappingTester<Baz>(model)
.Element("class").HasAttribute("batch-size", "10");
}
[Test]
public void InternalOverridesNotApplied()
{
var model = AutoMap.AssemblyOf<Baz>()
.Where(t => t.Namespace == typeof(Baz).Namespace)
.Alterations(x => x.Add(alteration));
new AutoMappingTester<Baz>(model)
.Element("class").HasAttribute("table", "`Baz`");
}
[Test]
public void RegularAutoMappingsStillWorkWhenOverridesApplied()
{
var model = AutoMap.AssemblyOf<Baz>()
.Where(t => t.Namespace == typeof(Baz).Namespace);
alteration.Alter(model);
new AutoMappingTester<Baz>(model)
.Element("class/property[@name='Name']").Exists();
}
[Test]
public void OverridesCanBeAbstract()
{
var model = AutoMap.AssemblyOf<Qux>()
.Where(t => t.Namespace == typeof(Qux).Namespace);
alteration.Alter(model);
new AutoMappingTester<Qux>(model)
.Element("class").HasAttribute("batch-size", "10");
}
}
}