Update of /cvsroot/jcframework/Nunit/InheritedClasses
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28092/InheritedClasses
Modified Files:
Tag: v2_0
AtomsFrameworkTests.vb
Log Message:
Extra unit test for collections and transaction rollbacks
Index: AtomsFrameworkTests.vb
===================================================================
RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/AtomsFrameworkTests.vb,v
retrieving revision 1.11.2.1
retrieving revision 1.11.2.2
diff -u -d -r1.11.2.1 -r1.11.2.2
--- AtomsFrameworkTests.vb 6 Feb 2005 02:49:52 -0000 1.11.2.1
+++ AtomsFrameworkTests.vb 7 Feb 2005 22:05:52 -0000 1.11.2.2
@@ -485,5 +485,60 @@
Assert.IsNull(a1.TableBCollection)
End Sub
- End Class
+ <Test()> Public Sub CheckCacheAfterRollback4()
+ 'Add and remove items in the collection during the transaction
+ Dim a As New TableA
+ Dim b As New TableB
+ Dim a1 As New TableA
+ a.Id = "aa4"
+ b.Id = "bb41"
+ b.TableA = a
+ a.TableBCollection.Add(b)
+ b = New TableB
+ b.Id = "bb42"
+ b.TableA = a
+ a.TableBCollection.Add(b)
+ a.Save()
+ Assert.AreEqual(2, a.TableBCollection.Count)
+ pbroker.startTransaction()
+ a1.Id = "aa4"
+ a1.Retrieve()
+ Assert.AreEqual(2, a1.TableBCollection.Count)
+ b = New TableB
+ b.Id = "bb43"
+ b.TableA = a
+ a.TableBCollection.Add(b)
+ b = New TableB
+ b.Id = "bb44"
+ b.TableA = a
+ a.TableBCollection.Add(b)
+ b = a.TableBCollection.Item(1)
+ Assert.AreEqual("bb42", b.Id)
+ a.TableBCollection.Remove(1)
+ b.Delete()
+ Assert.AreEqual(3, a.TableBCollection.Count)
+ a.Save()
+ a1 = New TableA
+ a1.Id = "aa4"
+ a1.Retrieve()
+ b = New TableB
+ b.Id = "bb42"
+ b.Retrieve()
+ Assert.IsFalse(b.Persistent)
+ Assert.AreEqual(3, a1.TableBCollection.Count)
+ 'Now abort the transaction
+ pbroker.rollback()
+ a1 = New TableA
+ a1.Id = "aa4"
+ a1.Retrieve()
+ b = New TableB
+ b.Id = "bb42"
+ b.Retrieve()
+ Assert.IsTrue(b.Persistent)
+ Assert.AreEqual(2, a1.TableBCollection.Count)
+ Assert.AreEqual("bb42", CType(a1.TableBCollection.Item(1), TableB).Id)
+ End Sub
+
+
+ End Class
End Namespace
\ No newline at end of file
|