forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeyPropertyRefFixture.cs
57 lines (48 loc) · 959 Bytes
/
KeyPropertyRefFixture.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
using System;
using NHibernate;
using NUnit.Framework;
namespace NHibernate.Test.PropertyRef
{
[TestFixture]
public class KeyPropertyRefFixture : TestCase
{
protected override string[] Mappings
{
get { return new string[] { "PropertyRef.KeyPropertyRef.hbm.xml" }; }
}
protected override string MappingsAssembly
{
get { return "NHibernate.Test"; }
}
protected override void OnTearDown()
{
using (ISession s = OpenSession())
{
s.Delete("from B");
s.Flush();
s.Delete("from A");
s.Flush();
}
}
[Test]
public void PropertyRefUsesOtherColumn()
{
const int ExtraId = 500;
A a = new A();
a.Name = "First";
a.ExtraId = ExtraId;
B b = new B();
b.Id = ExtraId;
b.Name = "Second";
ISession s = OpenSession();
s.Save(a);
s.Save(b);
s.Flush();
s.Close();
s = OpenSession();
A newA = s.Get<A>(a.Id);
Assert.AreEqual(1, newA.Items.Count);
s.Close();
}
}
}