File tree Expand file tree Collapse file tree 1 file changed +42
-1
lines changed
src/NHibernate.Test/MappingTest Expand file tree Collapse file tree 1 file changed +42
-1
lines changed Original file line number Diff line number Diff line change 1+ using System . Linq ;
2+ using System . Threading ;
13using NHibernate . Dialect ;
24using NHibernate . Mapping ;
35using NUnit . Framework ;
@@ -59,5 +61,44 @@ public void SchemaNameQuoted()
5961
6062 Assert . AreEqual ( "[schema].name" , tbl . GetQualifiedName ( dialect ) ) ;
6163 }
62- }
64+
65+ [ Test ]
66+ public void TablesUniquelyNamed ( )
67+ {
68+ Table tbl1 = new Table ( ) ;
69+ Table tbl2 = new Table ( ) ;
70+
71+ Assert . AreEqual ( tbl1 . UniqueInteger + 1 , tbl2 . UniqueInteger ) ;
72+ }
73+
74+ [ Test ]
75+ public void TablesUniquelyNamedOnlyWithinThread ( )
76+ {
77+ var uniqueIntegerList = new System . Collections . Concurrent . ConcurrentBag < int > ( ) ;
78+ var method = new ThreadStart ( ( ) =>
79+ {
80+ Table tbl1 = new Table ( ) ;
81+ Table tbl2 = new Table ( ) ;
82+
83+ // Store these values for later comparison
84+ uniqueIntegerList . Add ( tbl1 . UniqueInteger ) ;
85+ uniqueIntegerList . Add ( tbl2 . UniqueInteger ) ;
86+
87+ // Ensure that within a thread we have unique integers
88+ Assert . AreEqual ( tbl1 . UniqueInteger + 1 , tbl2 . UniqueInteger ) ;
89+ } ) ;
90+
91+ var thread1 = new Thread ( method ) ;
92+ var thread2 = new Thread ( method ) ;
93+
94+ thread1 . Start ( ) ;
95+ thread2 . Start ( ) ;
96+
97+ thread1 . Join ( ) ;
98+ thread2 . Join ( ) ;
99+
100+ Assert . AreEqual ( 4 , uniqueIntegerList . Count ) ;
101+ Assert . AreEqual ( 2 , uniqueIntegerList . Distinct ( ) . Count ( ) ) ;
102+ }
103+ }
63104}
You can’t perform that action at this time.
0 commit comments