File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 5
5
namespace NHibernate . Test . NHSpecificTest . NH3141
6
6
{
7
7
[ TestFixture ]
8
- public class ProxyIdPerformanceTest : BugTestCase
8
+ public class ProxyIdFixture : BugTestCase
9
9
{
10
10
private int id ;
11
11
@@ -48,6 +48,31 @@ public void ShouldUseIdDirectlyFromProxy()
48
48
//after fix: 0.8s
49
49
Console . WriteLine ( watch . Elapsed ) ;
50
50
}
51
+
52
+ [ Test ]
53
+ public void ShouldThrowExceptionIfIdChangedOnUnloadEntity ( )
54
+ {
55
+ using ( var s = OpenSession ( ) )
56
+ using ( var tx = s . BeginTransaction ( ) )
57
+ {
58
+ var entity = s . Load < Entity > ( id ) ;
59
+ entity . Id ++ ;
60
+ Assert . Throws < HibernateException > ( tx . Commit ) ;
61
+ }
62
+ }
63
+
64
+ [ Test ]
65
+ public void ShouldThrowExceptionIfIdChangedOnLoadEntity ( )
66
+ {
67
+ using ( var s = OpenSession ( ) )
68
+ using ( var tx = s . BeginTransaction ( ) )
69
+ {
70
+ var entity = s . Load < Entity > ( id ) ;
71
+ NHibernateUtil . Initialize ( entity ) ;
72
+ entity . Id ++ ;
73
+ Assert . Throws < HibernateException > ( tx . Commit ) ;
74
+ }
75
+ }
51
76
52
77
private Entity CreateInitializedProxy ( )
53
78
{
Original file line number Diff line number Diff line change 1098
1098
<Compile Include =" MappingByCode\IntegrationTests\NH3105\Fixture.cs" />
1099
1099
<Compile Include =" NHSpecificTest\NH3436\Fixture.cs" />
1100
1100
<Compile Include =" NHSpecificTest\NH3141\Entity.cs" />
1101
- <Compile Include =" NHSpecificTest\NH3141\ProxyIdPerformanceTest .cs" />
1101
+ <Compile Include =" NHSpecificTest\NH3141\ProxyIdFixture .cs" />
1102
1102
<Compile Include =" NHSpecificTest\NH941\Domain.cs" />
1103
1103
<Compile Include =" NHSpecificTest\NH941\Fixture.cs" />
1104
1104
<Compile Include =" NHSpecificTest\NH941\FixtureUsingList.cs" />
You can’t perform that action at this time.
0 commit comments