-
Notifications
You must be signed in to change notification settings - Fork 686
/
OneToManyIntegrationTester.cs
55 lines (49 loc) · 1.71 KB
/
OneToManyIntegrationTester.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
using FluentNHibernate.Cfg.Db;
using FluentNHibernate.Mapping;
using NUnit.Framework;
using NHibernate.Cfg;
namespace FluentNHibernate.Testing.DomainModel.Mapping
{
[TestFixture]
public class OneToManyIntegrationTester
{
private class OneToManyPersistenceModel : PersistenceModel
{
public override void Configure(NHibernate.Cfg.Configuration configuration)
{
Add(new ChildObjectMap());
Add(new OneToManyTargetMap());
base.Configure(configuration);
}
private class ChildObjectMap : ClassMap<ChildObject>
{
public ChildObjectMap()
{
Id(x => x.Id);
}
}
private class OneToManyTargetMap : ClassMap<OneToManyTarget>
{
public OneToManyTargetMap()
{
Id(x => x.Id);
HasMany(x => x.ListOfChildren).AsList();
HasMany(x => x.BagOfChildren).AsBag();
HasMany(x => x.SetOfChildren).AsSet();
HasMany(x => x.MapOfChildren).AsMap( x => x.Name);
HasMany(x => x.ArrayOfChildren).AsArray(x => x.Position);
}
}
}
[Test]
public void NHibernateCanLoadOneToManyTargetMapping()
{
var cfg = new SQLiteConfiguration()
.InMemory()
.ConfigureProperties(new Configuration());
var model = new OneToManyPersistenceModel();
model.Configure(cfg);
cfg.BuildSessionFactory();
}
}
}