forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIdentityGeneratorFixture.cs
55 lines (50 loc) · 1.16 KB
/
IdentityGeneratorFixture.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 System;
using System.Linq;
using NHibernate.Linq;
using NUnit.Framework;
namespace NHibernate.Test.IdTest
{
[TestFixture]
public class IdentityGeneratorFixture : IdFixtureBase
{
protected override string TypeName
{
get { return "Identity"; }
}
protected override bool AppliesTo(Dialect.Dialect dialect)
{
return dialect.SupportsIdentityColumns;
}
protected override void OnTearDown()
{
using (var s = OpenSession())
using (var t = s.BeginTransaction())
{
s.CreateQuery("delete System.Object").ExecuteUpdate();
t.Commit();
}
}
[Test(Description = "NH-926")]
public void NonTransactedInsert()
{
using (var s = OpenSession())
{
Assert.DoesNotThrow(() => s.Save(new IdentityClass()));
// No need to flush with identity generator.
Assert.AreEqual(1, s.Query<IdentityClass>().Count());
}
}
[Test]
public void TransactedInsert()
{
using (var s = OpenSession())
using (var t = s.BeginTransaction())
{
Assert.DoesNotThrow(() => s.Save(new IdentityClass()));
// No need to flush with identity generator.
Assert.AreEqual(1, s.Query<IdentityClass>().Count());
t.Commit();
}
}
}
}