From: Richard B. <rb...@us...> - 2004-11-01 21:27:27
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26746/InheritedClasses Modified Files: AtomsFrameworkTests.vb CSharedClasses.vb SharedTests.vb TableA_B.vb Log Message: New tests to check cache behaviour for collections, and shared table classes that repeat XML information from the parent. Index: CSharedClasses.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/CSharedClasses.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CSharedClasses.vb 19 Oct 2004 00:13:38 -0000 1.1 +++ CSharedClasses.vb 1 Nov 2004 21:27:10 -0000 1.2 @@ -3,6 +3,7 @@ Namespace InheritedClasses Public Class SharedParent Inherits CPersistentObject + Private _field1 As String Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New SharedParent @@ -11,15 +12,35 @@ Public Overrides Function IsValid() As Boolean Return True End Function + + Public Property Field1() As String + Get + Return _field1 + End Get + Set(ByVal Value As String) + _field1 = Value + SetDirtyFlag() + End Set + End Property End Class Public Class SharedChild Inherits SharedParent + Private _field2 As String + Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New SharedChild End Function + Public Property Field2() As String + Get + Return _field2 + End Get + Set(ByVal Value As String) + _field2 = Value + End Set + End Property End Class End Namespace \ No newline at end of file Index: SharedTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/SharedTests.vb,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SharedTests.vb 25 Oct 2004 07:14:15 -0000 1.3 +++ SharedTests.vb 1 Nov 2004 21:27:10 -0000 1.4 @@ -43,6 +43,8 @@ Dim origOid As String = String.Empty Dim newOid As String = String.Empty sc.IsDirty = True + sc.Field1 = "a" + sc.Field2 = "b" sc.Save() origOid = sc.OIDValue sc = New SharedChild @@ -61,11 +63,14 @@ Dim result As Boolean Dim origOid As String = String.Empty sc.IsDirty = True + sc.Field1 = "xx" + sc.Field2 = "yy" sc.Save() origOid = sc.OIDValue sp.OIDValue = origOid result = sp.Retrieve() Assert.IsTrue(sp.OIDValue = origOid) + Assert.AreEqual("xx", sp.Field1) Assert.IsTrue(result) Assert.IsFalse(sp.IsDirty) Assert.IsFalse(sp.GetType Is GetType(SharedChild)) Index: TableA_B.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/TableA_B.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- TableA_B.vb 21 Oct 2004 23:36:46 -0000 1.2 +++ TableA_B.vb 1 Nov 2004 21:27:10 -0000 1.3 @@ -26,7 +26,7 @@ End Set End Property - Private _tableBCol As New CPersistentCollection + Private WithEvents _tableBCol As New CPersistentCollection Public Property TableBCollection() As CPersistentCollection Get Return _tableBCol @@ -53,6 +53,10 @@ Public Overrides Function IsValid() As Boolean Return True End Function + + Private Sub _tableBCol_ItemDirtied(ByVal sender As Object, ByVal e As System.EventArgs) Handles _tableBCol.ItemDirtied + Me.SetDirtyFlag() + End Sub End Class Public Class TableB Index: AtomsFrameworkTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/AtomsFrameworkTests.vb,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- AtomsFrameworkTests.vb 31 Oct 2004 23:08:36 -0000 1.5 +++ AtomsFrameworkTests.vb 1 Nov 2004 21:27:10 -0000 1.6 @@ -266,5 +266,60 @@ Assert.AreEqual(4, a.TableCCollection.Count) End Sub + <Test()> Public Sub CheckCacheBehaviour() + Dim a As New TableA + Dim b As New TableB + Dim c As New TableC + a.Id = "aaa" + b.Id = "bbb1" + b.TableA = a + a.TableBCollection.Add(b) + b = New TableB + b.Id = "bbb2" + b.TableA = a + a.TableBCollection.Add(b) + b = New TableB + b.Id = "bbb3" + b.TableA = a + a.TableBCollection.Add(b) + b = New TableB + b.Id = "bbb4" + b.TableA = a + a.TableBCollection.Add(b) + c = New TableC + c.Id = "ccc1" + c.TableA = a + a.TableCCollection.Add(c) + c = New TableC + c.Id = "ccc2" + c.TableA = a + a.TableCCollection.Add(c) + a.Save() + Assert.AreEqual(4, a.TableBCollection.Count) + Assert.AreEqual(2, a.TableCCollection.Count) + pbroker.ClearCache() + a = New TableA + a.Id = "aaa" + a.Retrieve(a) + Assert.AreEqual(4, a.TableBCollection.Count) + Assert.AreEqual(2, a.TableCCollection.Count) + b = a.TableBCollection(2) + b.field1 = "a3" + b.Id = "bbb5" + Debug.WriteLine(pbroker.DumpCacheDetails()) + a = New TableA + a.Id = "aaa" + a.Retrieve(a, False) + 'Bug existed where code above caused cached objects to change values + Assert.AreEqual("bbb3", CType(a.TableBCollection(2), TableB).Id) + a.field1 = "aa2" + a.Save() + a = New TableA + a.Id = "aaa" + a.Retrieve(a, False) + Assert.AreEqual(4, a.TableBCollection.Count) + Assert.AreEqual(2, a.TableCCollection.Count) + End Sub + End Class End Namespace \ No newline at end of file |