From: Steven M. <sr...@us...> - 2005-05-23 00:29:55
|
Update of /cvsroot/instantobjects/Source/Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4881 Modified Files: TestInstantComplex.pas TestInstantElement.pas TestInstantPart.pas Log Message: Update to tests Index: TestInstantPart.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Tests/TestInstantPart.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestInstantPart.pas 14 May 2005 07:38:37 -0000 1.1 --- TestInstantPart.pas 23 May 2005 00:29:45 -0000 1.2 *************** *** 67,71 **** FInstantPart.Assign(vSource); AssertTrue(FInstantPart.HasValue); ! AssertNotSame(vSource, FInstantPart.Value); finally vSource.Free; --- 67,71 ---- FInstantPart.Assign(vSource); AssertTrue(FInstantPart.HasValue); ! AssertNotSame(vPart, FInstantPart.Value); finally vSource.Free; Index: TestInstantElement.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Tests/TestInstantElement.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestInstantElement.pas 14 May 2005 07:38:37 -0000 1.1 --- TestInstantElement.pas 23 May 2005 00:29:45 -0000 1.2 *************** *** 52,64 **** vObject := TInstantObject.Create(FConn); vObject.Id := 'Object.Id'; ! AssertNotNull('vObject', vObject); vReturnValue := FInstantElement.AttachObject(vObject); AssertTrue('AttachObject', vReturnValue); AssertSame(vObject, FInstantElement.Value); ! AssertTrue(FInstantElement.HasValue); - // ToDo: Why does this return false? vReturnValue := FInstantElement.DetachObject(vObject); ! AssertTrue('DetachObject', vReturnValue); // Fails?? end; --- 52,67 ---- vObject := TInstantObject.Create(FConn); vObject.Id := 'Object.Id'; ! AssertEquals('Object RefCount 1', 1, vObject.RefCount); ! vReturnValue := FInstantElement.AttachObject(vObject); AssertTrue('AttachObject', vReturnValue); AssertSame(vObject, FInstantElement.Value); ! AssertTrue('FInstantElement HasValue', FInstantElement.HasValue); ! AssertEquals('Value RefCount 1', 1, FInstantElement.Value.RefCount); ! AssertEquals('Object RefCount 2', 1, vObject.RefCount); vReturnValue := FInstantElement.DetachObject(vObject); ! AssertTrue('DetachObject', vReturnValue); ! AssertEquals('Object RefCount 3', 0, vObject.RefCount); end; *************** *** 76,82 **** --- 79,88 ---- vObject := TInstantObject.Create(FConn); AssertNotNull('Create object', vObject); + AssertEquals('Object RefCount 1', 1, vObject.RefCount); vReturnValue := FInstantElement.AttachObject(vObject); AssertTrue('AttachObject', vReturnValue); AssertTrue(FInstantElement.HasValue); + AssertEquals('Value RefCount 1', 1, FInstantElement.Value.RefCount); + AssertEquals('Object RefCount 2', 1, vObject.RefCount); vStream := TInstantStream.Create; *************** *** 86,92 **** --- 92,102 ---- FInstantElement.Value := nil; AssertFalse(FInstantElement.HasValue); + AssertEquals('Object RefCount 3', 0, vObject.RefCount); vStream.Position := 0; FInstantElement.LoadObjectFromStream(vStream); AssertTrue(FInstantElement.HasValue); + AssertEquals('Value RefCount 2', 1, FInstantElement.Value.RefCount); + AssertEquals('Object RefCount 4', 0, vObject.RefCount); + AssertNotSame(vObject, FInstantElement.Value); finally vStream.Free; *************** *** 98,101 **** --- 108,113 ---- {$IFNDEF CURR_TESTS} RegisterTests([TestTInstantElement]); + {$ELSE} + RegisterTests([TestTInstantElement]); {$ENDIF} Index: TestInstantComplex.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Tests/TestInstantComplex.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestInstantComplex.pas 14 May 2005 07:38:37 -0000 1.1 --- TestInstantComplex.pas 23 May 2005 00:29:40 -0000 1.2 *************** *** 3,7 **** interface ! uses fpcunit, InstantPersistence; type --- 3,7 ---- interface ! uses fpcunit, InstantPersistence, InstantMock; type *************** *** 11,15 **** --- 11,17 ---- private FAttrMetadata: TInstantAttributeMetadata; + FConn: TInstantMockConnector; FInstantComplex: TInstantComplex; + FOwner: TInstantObject; public procedure SetUp; override; *************** *** 30,37 **** procedure TestTInstantComplex.SetUp; begin FAttrMetadata := TInstantAttributeMetadata.Create(nil); FAttrMetadata.AttributeClass := TInstantComplex; FAttrMetadata.Name := 'AttrMetadataName'; ! FInstantComplex := TInstantComplex.Create(nil, FAttrMetadata); end; --- 32,42 ---- procedure TestTInstantComplex.SetUp; begin + FConn := TInstantMockConnector.Create(nil); + FConn.BrokerClass := TInstantMockBroker; + FOwner := TInstantObject.Create(FConn); FAttrMetadata := TInstantAttributeMetadata.Create(nil); FAttrMetadata.AttributeClass := TInstantComplex; FAttrMetadata.Name := 'AttrMetadataName'; ! FInstantComplex := TInstantComplex.Create(FOwner, FAttrMetadata); end; *************** *** 40,43 **** --- 45,50 ---- FreeAndNil(FInstantComplex); FreeAndNil(FAttrMetadata); + FreeAndNil(FOwner); + FreeAndNil(FConn); end; *************** *** 78,81 **** --- 85,90 ---- {$IFNDEF CURR_TESTS} RegisterTests([TestTInstantComplex]); + {$ELSE} + RegisterTests([TestTInstantComplex]); {$ENDIF} |