forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFixture.cs
115 lines (102 loc) · 2.84 KB
/
Fixture.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by AsyncGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using NHibernate.Cfg;
using NUnit.Framework;
using Environment = NHibernate.Cfg.Environment;
namespace NHibernate.Test.NHSpecificTest.GH1530
{
using System.Threading.Tasks;
[TestFixture]
public abstract class FixtureBaseAsync : BugTestCase
{
private Parent _parent;
protected override void OnSetUp()
{
using (var s = OpenSession())
{
using (var tx = s.BeginTransaction())
{
_parent = new Parent();
_parent.AddChild(new Child());
s.Save(_parent);
tx.Commit();
}
}
}
[Test]
public virtual async Task OneNewChildShouldOnlyCreateInsertWithNoUpdate_LockAndMergeAsync()
{
var parentClone = _parent.MakeCopy();
parentClone.AddChild(new Child());
using (var s = OpenSession())
{
using (var tx = s.BeginTransaction())
{
await (s.LockAsync(_parent, LockMode.None));
await (s.MergeAsync(parentClone));
s.SessionFactory.Statistics.Clear();
await (tx.CommitAsync());
}
Assert.That(s.SessionFactory.Statistics.PrepareStatementCount, Is.EqualTo(1));
}
}
[Test]
public virtual async Task OneNewChildShouldOnlyCreateInsertWithNoUpdate_MergeAsync()
{
var parentClone = _parent.MakeCopy();
parentClone.AddChild(new Child());
using (var s = OpenSession())
{
using (var tx = s.BeginTransaction())
{
await (s.MergeAsync(parentClone));
s.SessionFactory.Statistics.Clear();
await (tx.CommitAsync());
}
Assert.That(s.SessionFactory.Statistics.PrepareStatementCount, Is.EqualTo(1));
}
}
protected override void OnTearDown()
{
using (var s = OpenSession())
{
using (var tx = s.BeginTransaction())
{
s.Delete(s.Load<Parent>(_parent.Id));
tx.Commit();
}
}
}
protected override void Configure(Configuration configuration)
{
configuration.SetProperty(Environment.GenerateStatistics, "true");
}
}
[TestFixture]
public class FixtureAsync : FixtureBaseAsync
{
[Test]
[KnownBug("#1530")]
public override async Task OneNewChildShouldOnlyCreateInsertWithNoUpdate_MergeAsync()
{
await (base.OneNewChildShouldOnlyCreateInsertWithNoUpdate_MergeAsync());
}
[Test]
[KnownBug("#1530")]
public override async Task OneNewChildShouldOnlyCreateInsertWithNoUpdate_LockAndMergeAsync()
{
await (base.OneNewChildShouldOnlyCreateInsertWithNoUpdate_LockAndMergeAsync());
}
}
[TestFixture]
public class NonInverseFixtureAsync : FixtureBaseAsync
{
protected override string[] Mappings => new[] { "NonInverseMappings.hbm.xml" };
}
}