From: Richard B. <rb...@us...> - 2005-04-01 00:00:21
|
Update of /cvsroot/jcframework/Nunit/Interfaces In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15894/Interfaces Modified Files: ManyToManyTests.vb Added Files: IOptimistic.vb TimestampTests.vb Log Message: Unit tests for caching and event listeners, and also for timestamps on interfaces. --- NEW FILE: IOptimistic.vb --- Namespace Interfaces Public Interface IOptimistic Property GuidValue() As String Property Description() As String Property CreatedDate() As Date Property ModifiedDate() As Date End Interface Public Class COptimistic Implements IOptimistic Private m_guid As Guid = Guid.Empty Private m_description As String Private m_created As Date Private m_modified As Date Public Property Description() As String Implements IOptimistic.Description Get Return m_description End Get Set(ByVal Value As String) If Not String.Equals(m_description, Value) Then m_description = Value m_modified = Now End If End Set End Property Public Property GuidValue() As String Implements IOptimistic.GuidValue Get If m_guid.Equals(Guid.Empty) Then m_guid = Guid.NewGuid End If Return m_guid.ToString("N") End Get Set(ByVal value As String) m_guid = New Guid(value) End Set End Property Public Property CreatedDate() As Date Implements IOptimistic.CreatedDate Get Return m_created End Get Set(ByVal Value As Date) m_created = Value End Set End Property Public Property ModifiedDate() As Date Implements IOptimistic.ModifiedDate Get Return m_modified End Get Set(ByVal Value As Date) m_modified = Value End Set End Property Public Sub New() m_created = Now End Sub End Class Public Class IOptimisticFactory Implements AToMSFramework.IClassFactory Public Function CreateObject() As Object Implements AToMSFramework.IClassFactory.CreateObject Return New COptimistic End Function End Class End Namespace Index: ManyToManyTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/Interfaces/ManyToManyTests.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ManyToManyTests.vb 1 Mar 2005 20:51:33 -0000 1.2 +++ ManyToManyTests.vb 1 Apr 2005 00:00:10 -0000 1.3 @@ -37,7 +37,7 @@ Dim gval As String Dim x As Integer, y As Integer A = New M2MA - pbroker.StartTracking(A) + pbroker.GetObject(A) A.Description = "A-one" gval = A.GUIDValue B = New M2MB @@ -79,7 +79,7 @@ Dim gval As String Dim x As Integer, y As Integer A = New M2MA - pbroker.StartTracking(A) + pbroker.GetObject(A) A.Description = "A1" gval = A.GUIDValue B = New M2MB @@ -129,7 +129,7 @@ Dim gvalA, gvalB As String Dim s As String A = New M2MA - pbroker.StartTracking(A) + pbroker.GetObject(A) A.Description = "A1" gvalA = A.GUIDValue B = New M2MB @@ -149,7 +149,7 @@ Dim gvalA, gvalB As String Dim s As String A = New M2MA - pbroker.StartTracking(A) + pbroker.GetObject(A) A.Description = "A1" gvalA = A.GUIDValue B = New M2MB --- NEW FILE: TimestampTests.vb --- Imports AToMSFramework Imports NUnit.Framework Namespace Interfaces <TestFixture()> Public Class TimestampTests Private pbroker As CPersistenceBroker Private opt As IOptimistic <TestFixtureSetUp()> Public Sub Init() Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory Dim retry As Boolean = True While retry = True Try 'Remove any existing test database System.IO.File.Delete(".\db1.mdb") retry = False Catch iox As IO.IOException 'file is in use - so we will loop around until it is released Catch ex As Exception retry = False End Try End While System.IO.File.Copy(".\original db1.mdb", ".\db1.mdb") pbroker = New CPersistenceBroker pbroker.init() End Sub <TestFixtureTearDown()> Public Sub Dispose() pbroker.Dispose() pbroker = Nothing End Sub <SetUp()> Public Sub TestInit() opt = New COptimistic End Sub <Test()> Public Sub SaveAndModify() Dim gVal As String gVal = opt.GuidValue pbroker.GetObject(opt) opt.Description = "a" pbroker.PersistChanges(opt) pbroker.ClearCache() opt = New COptimistic opt.GuidValue = gVal pbroker.GetObject(opt) Assert.AreEqual("a", opt.Description) opt.Description = "b" pbroker.PersistChanges(opt) End Sub End Class End Namespace |