forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimplyManyToOneIgnoreTest.cs
57 lines (52 loc) · 1.31 KB
/
SimplyManyToOneIgnoreTest.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 System.Collections;
using NUnit.Framework;
namespace NHibernate.Test.Unconstrained
{
// represent another possible ""normal"" use (N.B. H3 create the FK if you don't use <formula>)
[TestFixture]
public class SimplyManyToOneIgnoreTest : TestCase
{
protected override string MappingsAssembly
{
get { return "NHibernate.Test"; }
}
protected override string[] Mappings
{
get { return new string[] {"Unconstrained.Simply.hbm.xml"}; }
}
[Test]
public void Unconstrained()
{
using (ISession s = OpenSession())
using (ITransaction t = s.BeginTransaction())
{
SimplyB sb = new SimplyB(100);
SimplyA sa = new SimplyA("ralph");
sa.SimplyB = sb;
s.Save(sb);
s.Save(sa);
t.Commit();
}
using (ISession s = OpenSession())
{
using (ITransaction t = s.BeginTransaction())
{
SimplyB sb = (SimplyB) s.Get(typeof(SimplyB), 100);
Assert.IsNotNull(sb);
s.Delete(sb);
t.Commit();
}
// Have to do this in a separate transaction, otherwise ISession.Get retrieves
// the cached version of SimplyA with its B being not null.
using (ITransaction t = s.BeginTransaction())
{
SimplyA sa = (SimplyA) s.Get(typeof(SimplyA), "ralph");
Assert.IsNull(sa.SimplyB);
s.Delete(sa);
t.Commit();
}
}
}
}
}