1
- using System ;
2
- using System . Collections ;
3
- using System . Collections . Generic ;
4
- using System . Text ;
5
- using NHibernate . Dialect ;
6
- using NUnit . Framework ;
7
- using NHibernate . Test . NHSpecificTest ;
8
- using Iesi . Collections . Generic ;
9
- using NHibernate ;
10
- using System . Data ;
11
- using NHibernate . Criterion ;
1
+ using NUnit . Framework ;
12
2
13
3
namespace NHibernate . Test . NHSpecificTest . NH3898
14
4
{
15
- /// <summary>
16
- /// <para>
17
- /// </para>
18
- /// </remarks>
19
5
[ TestFixture ]
20
6
public class Fixture : BugTestCase
21
7
{
22
- protected override void Configure ( NHibernate . Cfg . Configuration configuration )
8
+ protected override void Configure ( Cfg . Configuration configuration )
23
9
{
24
- #region removing possible second-level-cache configs
25
- configuration . Properties . Remove ( NHibernate . Cfg . Environment . CacheProvider ) ;
26
- configuration . Properties . Remove ( NHibernate . Cfg . Environment . UseQueryCache ) ;
27
- configuration . Properties . Add ( NHibernate . Cfg . Environment . UseQueryCache , "true" ) ;
28
- configuration . Properties . Remove ( NHibernate . Cfg . Environment . UseSecondLevelCache ) ;
29
- #endregion
30
-
31
- base . Configure ( configuration ) ;
10
+ configuration . SetProperty ( Cfg . Environment . UseQueryCache , "false" ) ;
11
+ configuration . SetProperty ( Cfg . Environment . UseSecondLevelCache , "false" ) ;
32
12
}
33
13
34
14
protected override void OnTearDown ( )
35
15
{
36
- base . OnTearDown ( ) ;
37
- using ( ISession s = OpenSession ( ) )
16
+ using ( var s = OpenSession ( ) )
17
+ using ( var tx = s . BeginTransaction ( ) )
38
18
{
39
- int countUpdate = 0 ;
40
-
41
- countUpdate =
42
- s
43
- . CreateSQLQuery ( "DELETE FROM T_EMPLOYEE" )
44
- . ExecuteUpdate ( ) ;
45
- Assert . AreEqual ( 1 , countUpdate ) ;
19
+ s . CreateQuery ( "delete from Employee" ) . ExecuteUpdate ( ) ;
46
20
47
- s . Flush ( ) ;
21
+ tx . Commit ( ) ;
48
22
}
49
23
}
50
24
51
- protected override void OnSetUp ( )
52
- {
53
- base . OnSetUp ( ) ;
54
- }
55
-
56
- protected override bool AppliesTo ( global ::NHibernate . Dialect . Dialect dialect )
57
- {
58
- //return dialect as MsSql2005Dialect != null;
59
- return base . AppliesTo ( dialect ) ;
60
- }
61
-
62
- /// <summary>
63
- /// Test that reproduces the problem.
64
- /// </summary>
65
25
[ Test ]
66
26
public void GeneratedInsertUpdateTrue ( )
67
27
{
68
- using ( ISession session = this . OpenSession ( ) )
28
+ object id ;
29
+ using ( var session = OpenSession ( ) )
30
+ using ( var tx = session . BeginTransaction ( ) )
69
31
{
70
- using ( ITransaction tx = session . BeginTransaction ( ) )
32
+ var employee = new Employee
71
33
{
72
- Employee employee = new Employee ( ) ;
73
- employee . Id = 1 ;
74
- employee . Name = "Employee 1" ;
75
- employee . PromotionCount = 9999999 ;
76
- session . Save ( employee ) ;
77
- Assert . AreEqual ( 0 , employee . PromotionCount ) ;
78
- tx . Commit ( ) ;
79
- }
34
+ Name = "Employee 1" ,
35
+ PromotionCount = 9999999
36
+ } ;
37
+ id = session . Save ( employee ) ;
38
+ Assert . That ( employee . PromotionCount , Is . EqualTo ( 0 ) ) ;
39
+ tx . Commit ( ) ;
80
40
}
81
41
82
- using ( ISession session = this . OpenSession ( ) )
42
+ using ( var session = OpenSession ( ) )
43
+ using ( var tx = session . BeginTransaction ( ) )
83
44
{
84
- using ( ITransaction tx = session . BeginTransaction ( ) )
85
- {
86
- Employee employee = session . Get < Employee > ( 1 ) ;
87
- employee . Name = "Employee 1 changed" ;
88
- employee . PromotionCount ++ ;
89
- Assert . AreEqual ( 1 , employee . PromotionCount ) ;
90
- tx . Commit ( ) ;
91
- }
45
+ var employee = session . Get < Employee > ( id ) ;
46
+ employee . Name = "Employee 1 changed" ;
47
+ employee . PromotionCount ++ ;
48
+ Assert . That ( employee . PromotionCount , Is . EqualTo ( 1 ) ) ;
49
+ tx . Commit ( ) ;
92
50
}
93
51
94
- using ( ISession session = this . OpenSession ( ) )
52
+ using ( var session = OpenSession ( ) )
53
+ using ( session . BeginTransaction ( ) )
95
54
{
96
- Employee employee = session . Get < Employee > ( 1 ) ;
97
- Assert . AreEqual ( "Employee 1 changed" , employee . Name ) ;
98
- Assert . AreEqual ( 1 , employee . PromotionCount ) ;
55
+ var employee = session . Get < Employee > ( id ) ;
56
+ Assert . That ( employee . Name , Is . EqualTo ( "Employee 1 changed" ) ) ;
57
+ Assert . That ( employee . PromotionCount , Is . EqualTo ( 1 ) ) ;
99
58
}
100
59
}
101
60
}
102
- }
61
+ }
0 commit comments