public void Test_ThrowErrorIfSecondInstanceOfContactPersonBeginEdit() { //---------------Set up test pack------------------- var cp = CreateSavedContactPersonPessimisticLocking(); FixtureEnvironment.ClearBusinessObjectManager(); var cp2 = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <ContactPersonPessimisticLockingDB>(cp.ID); //---------------Execute Test ---------------------- string surname = cp.Surname; cp.Surname = Guid.NewGuid().ToString(); try { cp2.Surname = Guid.NewGuid().ToString(); Assert.Fail(); } //---------------Test Result ----------------------- catch (BusObjPessimisticConcurrencyControlException ex) { Assert.AreEqual(surname, cp2.Surname); Assert.IsTrue( ex.Message.Contains( "You cannot begin edits on the 'ContactPersonPessimisticLockingDB', as another user has started edits and therefore locked to this record.")); } }
public void TestSerialiseDeserialiseBOPropStatusIsIncluded() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); BORegistry.DataAccessor = new DataAccessorInMemory(); Structure.Car.LoadDefaultClassDef(); OrganisationPerson.LoadDefaultClassDef(); Person.LoadDefaultClassDef(); Person originalPerson = Person.CreateSavedPerson(); IFormatter formatter = new BinaryFormatter(); MemoryStream memoryStream = new MemoryStream(); FixtureEnvironment.ClearBusinessObjectManager(); originalPerson.FirstName = "Bob"; //---------------Assert PreConditions--------------- Assert.IsTrue(originalPerson.Props["FirstName"].IsDirty); //---------------Execute Test ---------------------- formatter.Serialize(memoryStream, originalPerson); memoryStream.Seek(0, SeekOrigin.Begin); Person deserialisedPerson = (Person)formatter.Deserialize(memoryStream); //---------------Test Result ----------------------- Assert.IsTrue(deserialisedPerson.Props["FirstName"].IsDirty); }
public void Test_AddedChild_UpdatesRelatedPropertiesOnlyWhenParentSaves_DB_CompositeKey() { //---------------Set up test pack------------------- TestUsingDatabase.SetupDBDataAccessor(); Car car = new Car(); car.Save(); ContactPersonCompositeKey contactPerson = new ContactPersonCompositeKey(); contactPerson.PK1Prop1 = TestUtil.GetRandomString(); contactPerson.PK1Prop2 = TestUtil.GetRandomString(); contactPerson.Save(); contactPerson.GetCarsDriven().Add(car); //---------------Assert PreConditions--------------- Assert.AreEqual(contactPerson.PK1Prop1, car.DriverFK1); Assert.AreEqual(contactPerson.PK1Prop2, car.DriverFK2); //---------------Execute Test ---------------------- contactPerson.Save(); FixtureEnvironment.ClearBusinessObjectManager(); Car loadedCar = Broker.GetBusinessObject <Car>(car.ID); //---------------Test Result ----------------------- Assert.AreEqual(contactPerson.PK1Prop1, loadedCar.DriverFK1); Assert.AreEqual(contactPerson.PK1Prop2, loadedCar.DriverFK2); }
public void SetupTest() { //Runs every time that any testmethod is executed FixtureEnvironment.ClearBusinessObjectManager(); GlobalRegistry.SecurityController = null; //new Address(); }
public void TestBoLoader_RefreshBusinessObjectDeletedByAnotherUser() { //-------------Setup Test Pack------------------ SetupDefaultContactPersonBO(); ContactPersonTestBO cpTemp = ContactPersonTestBO.CreateSavedContactPerson(); FixtureEnvironment.ClearBusinessObjectManager(); ContactPersonTestBO cpLoaded = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <ContactPersonTestBO>(cpTemp.ID); cpTemp.MarkForDelete(); cpTemp.Save(); //-------------Execute Test --------------------- try { BORegistry.DataAccessor.BusinessObjectLoader.Refresh(cpLoaded); Assert.Fail(); } //-------------Test Result --------------------- catch (BusObjDeleteConcurrencyControlException ex) { StringAssert.Contains ("A Error has occured since the object you are trying to refresh has been deleted by another user.", ex.Message); StringAssert.Contains("There are no records in the database for the Class", ex.Message); StringAssert.Contains("ContactPersonTestBO", ex.Message); StringAssert.Contains(cpLoaded.ID.ToString(), ex.Message); } }
public void Test_RefreshCollectionRefreshesNonDirtyObjects() { //---------------Set up test pack------------------- BORegistry.DataAccessor = new DataAccessorDB(); OrganisationTestBO.DeleteAllOrganisations(); ContactPersonTestBO.DeleteAllContactPeople(); SetupDefaultContactPersonBO(); var col = new BusinessObjectCollection <ContactPersonTestBO>(); var cp1 = CreateContactPersonTestBO(); FixtureEnvironment.ClearBusinessObjectManager(); CreateContactPersonTestBO(); CreateContactPersonTestBO(); col.LoadAll(); var newSurname = Guid.NewGuid().ToString(); cp1.Surname = newSurname; cp1.Save(); var secondInstanceOfCP1 = col.Find(cp1.ContactPersonID); //--------------------Assert Preconditions---------- AssertNotContains(cp1, col); Assert.AreEqual(newSurname, cp1.Surname); Assert.AreNotSame(secondInstanceOfCP1, cp1); Assert.AreNotEqual(newSurname, secondInstanceOfCP1.Surname); Assert.IsFalse(cp1.Status.IsDirty); //---------------Execute Test ---------------------- col.Refresh(); //---------------Test Result ----------------------- Assert.AreNotSame(secondInstanceOfCP1, cp1); Assert.AreEqual(newSurname, secondInstanceOfCP1.Surname); }
public void Test_ReturnSameObjectFromBusinessObjectLoader() { //---------------Set up test pack------------------- //------------------------------Setup Test new Engine(); new Car(); ContactPerson originalContactPerson = new ContactPerson(); originalContactPerson.Surname = "FirstSurname"; originalContactPerson.Save(); FixtureEnvironment.ClearBusinessObjectManager(); //load second object from DB to ensure that it is now in the object manager ContactPerson myContact2 = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <ContactPerson> (originalContactPerson.ID); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- ContactPerson myContact3 = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <ContactPerson> (originalContactPerson.ID); //---------------Test Result ----------------------- // Assert.AreNotSame(originalContactPerson, myContact3); Assert.AreSame(myContact2, myContact3); }
public void TestCreateRelationshipHoldRelRef() { RelationshipDef mRelationshipDef; RelKeyDef mRelKeyDef; MockBO _mMockBO = GetMockBO(out mRelationshipDef, out mRelKeyDef); RelationshipDef lRelationshipDef = new SingleRelationshipDef("Relation1", typeof(MockBO), mRelKeyDef, true, DeleteParentAction.Prevent); ISingleRelationship rel = (ISingleRelationship)lRelationshipDef.CreateRelationship(_mMockBO, _mMockBO.PropCol); Assert.AreEqual(lRelationshipDef.RelationshipName, rel.RelationshipName); Assert.IsTrue(_mMockBO.GetPropertyValue("MockBOProp1") == null); Assert.IsFalse(rel.HasRelatedObject(), "Should be false since props are not defaulted in Mock bo"); _mMockBO.SetPropertyValue("MockBOProp1", _mMockBO.GetPropertyValue("MockBOID")); _mMockBO.Save(); Assert.IsTrue(rel.HasRelatedObject(), "Should be true since prop MockBOProp1 has been set"); Assert.AreEqual(_mMockBO.GetPropertyValue("MockBOProp1"), _mMockBO.GetPropertyValue("MockBOID")); MockBO ltempBO = (MockBO)rel.GetRelatedObject(); Assert.IsFalse(ltempBO == null); Assert.AreEqual(_mMockBO.GetPropertyValue("MockBOID"), ltempBO.GetPropertyValue("MockBOID"), "The object returned should be the one with the ID = MockBOID"); Assert.AreEqual(_mMockBO.GetPropertyValueString("MockBOProp1"), ltempBO.GetPropertyValueString("MockBOID"), "The object returned should be the one with the ID = MockBOID"); Assert.AreEqual(_mMockBO.GetPropertyValue("MockBOProp1"), ltempBO.GetPropertyValue("MockBOID"), "The object returned should be the one with the ID = MockBOID"); Assert.IsTrue(ReferenceEquals(ltempBO, rel.GetRelatedObject())); FixtureEnvironment.ClearBusinessObjectManager(); Assert.IsTrue(ReferenceEquals(ltempBO, rel.GetRelatedObject())); _mMockBO.MarkForDelete(); _mMockBO.Save(); }
public void TestDeleteObjectPriorToUpdatesConcurrencyControl() { //----------SETUP TEST PACK-------------------------- ContactPersonOptimisticLockingVersionNumberDB contactPersonDeleteConcurrency = CreateSavedCntactPersonOptimisticLockingVersionNumberDB(); //Clear object manager FixtureEnvironment.ClearBusinessObjectManager(); //Load second object from DB ContactPersonOptimisticLockingVersionNumberDB contactPerson2 = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <ContactPersonOptimisticLockingVersionNumberDB>(contactPersonDeleteConcurrency.ID); //---------Run TEST --------------------------------- contactPersonDeleteConcurrency.MarkForDelete(); contactPerson2.Surname = "New Surname 2"; contactPersonDeleteConcurrency.Save(); try { contactPerson2.Save(); Assert.Fail(); } //--------Check Result -------------------------------- catch (BusObjDeleteConcurrencyControlException ex) { Assert.IsTrue(ex.Message.Contains("You cannot save the changes to 'ContactPersonOptimisticLockingVersionNumberDB', as another user has deleted the record")); } }
public void Setup() { ClassDef.ClassDefs.Clear(); BOWithIntID.LoadClassDefWithIntID(); FixtureEnvironment.SetupInMemoryDataAccessor(); FixtureEnvironment.SetupNewIsolatedBusinessObjectManager(); }
public void Test_CreateDisplayValueDictionary_NoSort() { //--------------- Set up test pack ------------------ ClassDef.ClassDefs.Clear(); MyBO.LoadDefaultClassDef(); MyBO.DeleteAllMyBos(); FixtureEnvironment.ClearBusinessObjectManager(); TestUtil.WaitForGC(); MyBO myBO1 = new MyBO(); myBO1.Save(); MyBO myBO2 = new MyBO(); myBO2.Save(); MyBO myBO3 = new MyBO(); myBO3.Save(); BusinessObjectCollection <MyBO> myBOs = new BusinessObjectCollection <MyBO>(); myBOs.LoadAll(); //--------------- Test Preconditions ---------------- //--------------- Execute Test ---------------------- Dictionary <string, string> dictionary = BusinessObjectLookupList.CreateDisplayValueDictionary(myBOs, false, Convert.ToString); //--------------- Test Result ----------------------- Assert.AreEqual(3, dictionary.Count); Assert.IsTrue(dictionary.ContainsValue(myBO1.ID.ToString())); Assert.IsTrue(dictionary.ContainsValue(myBO2.ID.ToString())); Assert.IsTrue(dictionary.ContainsValue(myBO3.ID.ToString())); }
public void Test_LoadExistingBO_AllowRead_True() { //---------------Set up test pack------------------- MyBoAuthenticationStub.LoadDefaultClassDef(); IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanCreate_True(); MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub(); myBoStub.SetAuthorisation(authorisationStub); myBoStub.Save(); authorisationStub = GetAuthorisationStub_CanRead_True(); myBoStub.SetAuthorisation(authorisationStub); IPrimaryKey id = myBoStub.ID; FixtureEnvironment.ClearBusinessObjectManager(); //---------------Assert Precondition---------------- Assert.IsTrue(authorisationStub.IsAuthorised(myBoStub, BusinessObjectActions.CanRead)); Assert.IsFalse(myBoStub.Status.IsNew); //---------------Execute Test ---------------------- myBoStub = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <MyBoAuthenticationStub>(id); object value = myBoStub.GetPropertyValue("Prop1"); //---------------Test Result ----------------------- Assert.IsNull(value); Assert.IsFalse(myBoStub.Status.IsDirty); }
public void TestLoadingRelatedObjectWithSingleTableInheritance() { //---------------Set up test pack------------------- DatabaseConnection.CurrentConnection.ExecuteRawSql( "delete from filledcircle_table; delete from circle_table; delete from shape_table"); //MyBO has a relationship to Shape. Shape potentially has a circle for single table inheritance. MyBO.LoadClassDefWithShape_SingleTableInheritance_Relationship(); MyBO bo = new MyBO(); CircleNoPrimaryKey circle = new CircleNoPrimaryKey(); circle.Radius = 5; circle.ShapeName = "MyShape"; circle.Save(); bo.SetPropertyValue("ShapeID", circle.ShapeID); bo.Save(); FixtureEnvironment.ClearBusinessObjectManager(); //---------------Execute Test ---------------------- bo = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <MyBO>(bo.ID); Shape shape = bo.Shape; //---------------Test Result ----------------------- Assert.AreSame(typeof(CircleNoPrimaryKey), shape.GetType()); Assert.IsFalse(shape.Status.IsNew); Assert.IsFalse(shape.Status.IsDeleted); Assert.IsFalse(shape.Status.IsEditing); Assert.IsFalse(shape.Status.IsDirty); Assert.IsTrue(shape.Status.IsValid()); }
public void Test_Refresh_AfterLoadIsCalled_IfObjectUpdatedInLoading() { //---------------Set up test pack--------------------- ClassDef.ClassDefs.Clear(); SetupDefaultContactPersonBO(); ContactPersonTestBO cp = new ContactPersonTestBO(); cp.Surname = Guid.NewGuid().ToString(); cp.Save(); FixtureEnvironment.ClearBusinessObjectManager(); ContactPersonTestBO cpLoaded = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <ContactPersonTestBO>(cp.ID); string newFirstname = cp.FirstName = TestUtil.GetRandomString(); cp.Save(); cpLoaded.AfterLoadCalled = false; //---------------Assert Precondition------------------ Assert.IsFalse(cpLoaded.AfterLoadCalled); //---------------Execute Test ------------------------ BORegistry.DataAccessor.BusinessObjectLoader.Refresh(cpLoaded); //---------------Test Result ------------------------- Assert.IsTrue(cpLoaded.AfterLoadCalled); Assert.AreNotSame(cp, cpLoaded); Assert.AreEqual(cp.FirstName, cpLoaded.FirstName); Assert.AreEqual(newFirstname, cpLoaded.FirstName); }
public void Test_LoadExistingBO_Fail_AllowRead_False() { //---------------Set up test pack------------------- MyBoAuthenticationStub.LoadDefaultClassDef(); IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanCreate_True(); MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub(); myBoStub.SetAuthorisation(authorisationStub); myBoStub.Save(); authorisationStub = GetAuthorisationStub_CanRead_False(); myBoStub.SetAuthorisation(authorisationStub); IPrimaryKey id = myBoStub.ID; FixtureEnvironment.ClearBusinessObjectManager(); //---------------Assert Precondition---------------- Assert.IsFalse(authorisationStub.IsAuthorised(myBoStub, BusinessObjectActions.CanRead)); Assert.IsFalse(myBoStub.Status.IsNew); //---------------Execute Test ---------------------- myBoStub = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <MyBoAuthenticationStub>(id); try { myBoStub.GetPropertyValue("Prop1"); Assert.Fail("expected Err"); } //---------------Test Result ----------------------- catch (BusObjReadException ex) { StringAssert.Contains("The logged on user", ex.Message); StringAssert.Contains("is not authorised to read ", ex.Message); } }
public void Test_Refresh_UpdatedEventIsFired_IfObjectUpdatedInLoading() { //---------------Set up test pack--------------------- ClassDef.ClassDefs.Clear(); SetupDefaultContactPersonBO(); ContactPersonTestBO cp = new ContactPersonTestBO(); cp.Surname = Guid.NewGuid().ToString(); cp.Save(); FixtureEnvironment.ClearBusinessObjectManager(); ContactPersonTestBO cpLoaded = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <ContactPersonTestBO>(cp.ID); string newFirstname = cp.FirstName = TestUtil.GetRandomString(); cp.Save(); bool updatedEventFired = false; cpLoaded.Updated += (sender, args) => updatedEventFired = true; //---------------Assert Precondition------------------ Assert.IsFalse(updatedEventFired); //---------------Execute Test ------------------------ BORegistry.DataAccessor.BusinessObjectLoader.Refresh(cpLoaded); //---------------Test Result ------------------------- Assert.IsTrue(updatedEventFired); }
public void SetupTest() { //Runs every time that any testmethod is executed ClassDef.ClassDefs.Clear(); FixtureEnvironment.ClearBusinessObjectManager(); BORegistry.DataAccessor = new DataAccessorDB(); }
public void Test_Serialise_AddBOPropAndDeserialise() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); BORegistry.DataAccessor = new DataAccessorInMemory(); Structure.Car.LoadDefaultClassDef(); OrganisationPerson.LoadDefaultClassDef(); IClassDef personClassDef = Person.LoadDefaultClassDef(); Person originalPerson = Person.CreateSavedPerson(); IFormatter formatter = new BinaryFormatter(); MemoryStream memoryStream = new MemoryStream(); FixtureEnvironment.ClearBusinessObjectManager(); //---------------Execute Test ---------------------- formatter.Serialize(memoryStream, originalPerson); const string newpropertyName = "NewProperty"; const string defaultValue = "some Default"; personClassDef.PropDefcol.Add(new PropDef(newpropertyName, typeof(string), PropReadWriteRule.ReadWrite, defaultValue)); memoryStream.Seek(0, SeekOrigin.Begin); Person deserialisedPerson = (Person)formatter.Deserialize(memoryStream); //---------------Test Result ----------------------- Assert.AreNotSame(deserialisedPerson, originalPerson); AssertPersonsAreEqual(originalPerson, deserialisedPerson); Assert.AreEqual(defaultValue, deserialisedPerson.GetPropertyValue(newpropertyName)); }
public void CreateTestPack() { SetupDBConnection(); new Engine(); new Address(); ContactPerson.DeleteAllContactPeople(); new Car(); CreateUpdatedContactPersonTestPack(); _contactPersonUpdateConcurrency = new ContactPerson(); _contactPersonUpdateConcurrency.Surname = "Update Concurrency"; _contactPersonUpdateConcurrency.Save(); _contactPBeginEditsConcurrency = new ContactPerson(); _contactPBeginEditsConcurrency.Surname = "BeginEdits Concurrency"; _contactPBeginEditsConcurrency.Save(); _contactPTestRefreshFromObjMan = new ContactPerson(); _contactPTestRefreshFromObjMan.Surname = "FirstSurname"; _contactPTestRefreshFromObjMan.Save(); new Engine(); CreateDeletedPersonTestPack(); CreateSaveContactPersonTestPack(); //Ensure that a fresh object is loaded from DB FixtureEnvironment.ClearBusinessObjectManager(); }
public void TestSerialiseDeserialiseBusinessObjectCollection_EventsAreSetUp() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); BORegistry.DataAccessor = new DataAccessorInMemory(); Structure.Car.LoadDefaultClassDef(); OrganisationPerson.LoadDefaultClassDef(); Person.LoadDefaultClassDef(); BusinessObjectCollection <Person> originalPeople = new BusinessObjectCollection <Person>(); Person person1 = Person.CreateSavedPerson(); originalPeople.Add(person1); IFormatter formatter = new BinaryFormatter(); MemoryStream memoryStream = new MemoryStream(); FixtureEnvironment.ClearBusinessObjectManager(); bool eventFired = false; //---------------Execute Test ---------------------- formatter.Serialize(memoryStream, originalPeople); memoryStream.Seek(0, SeekOrigin.Begin); BusinessObjectCollection <Person> deserialisedPeople = (BusinessObjectCollection <Person>)formatter.Deserialize(memoryStream); deserialisedPeople.BusinessObjectPropertyUpdated += (sender, args) => eventFired = true; deserialisedPeople[0].FirstName = "new firstname"; //---------------Test Result ----------------------- Assert.IsTrue(eventFired); }
public override void SetupTest() { base.SetupTest(); FixtureEnvironment.ResetBORegistryBusinessObjectManager(); TestUsingDatabase.SetupDBDataAccessor(); OrganisationTestBO.DeleteAllOrganisations(); ContactPersonTestBO.DeleteAllContactPeople(); }
public override void SetupTest() { SetupDataAccessor(); FixtureEnvironment.ClearBusinessObjectManager(); TestUtil.WaitForGC(); ClassDef.ClassDefs.Clear(); //new Address(); }
public virtual void SetupTest() { ClassDef.ClassDefs.Clear(); SetupDataAccessor(); FixtureEnvironment.ResetBORegistryBusinessObjectManager(); FixtureEnvironment.ClearBusinessObjectManager(); TestUtil.WaitForGC(); }
public void TestFixtureSetup() { //Code that is executed before any test is run in this class. If multiple tests // are executed then it will still only be called once. FixtureEnvironment.SetupInMemoryDataAccessor(); FixtureEnvironment.ResetBORegistryBusinessObjectManager(); FixtureEnvironment.ClearBusinessObjectManager(); }
public void SetupTest() { //Runs every time that any testmethod is executed //base.SetupTest(); ClassDef.ClassDefs.Clear(); //new Address(); FixtureEnvironment.ResetBORegistryBusinessObjectManager(); FixtureEnvironment.ClearBusinessObjectManager(); }
public void Setup() { FixtureEnvironment.SetupNewIsolatedBusinessObjectManager(); ClassDef.ClassDefs.Clear(); BORegistry.DataAccessor = new DataAccessorDB(); FixtureEnvironment.ClearBusinessObjectManager(); TestUtil.WaitForGC(); _originalBusinessObjectManager = BORegistry.BusinessObjectManager; }
public virtual void SetupTest() { ClassDef.ClassDefs.Clear(); FixtureEnvironment.SetupInMemoryDataAccessor(); FixtureEnvironment.ResetBORegistryBusinessObjectManager(); BORegistry.BusinessObjectManager = new BusinessObjectManager(); ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse(); OrganisationTestBO.LoadDefaultClassDef_PreventAddChild(); }
public void TestFixtureSetup() { ClassDef.ClassDefs.Clear(); GlobalRegistry.UIExceptionNotifier = new RethrowingExceptionNotifier(); FixtureEnvironment.SetupInMemoryDataAccessor(); FixtureEnvironment.ResetBORegistryBusinessObjectManager(); AddressTestBO.LoadDefaultClassDef(); ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse(); OrganisationTestBO.LoadDefaultClassDef(); }
public void TestSerialiseDeserialiseBusinessObjectCollection_HavingAllCollections() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); BORegistry.DataAccessor = new DataAccessorInMemory(); Structure.Car.LoadDefaultClassDef(); OrganisationPerson.LoadDefaultClassDef(); Person.LoadDefaultClassDef(); BusinessObjectCollection <Person> originalPeople = new BusinessObjectCollection <Person>(); Person persistedPerson = originalPeople.CreateBusinessObject(); Person deletedPerson = originalPeople.CreateBusinessObject(); Person removedPerson = originalPeople.CreateBusinessObject(); originalPeople.SaveAll(); originalPeople.Remove(removedPerson); deletedPerson.MarkForDelete(); Person createdPerson = originalPeople.CreateBusinessObject(); Person addedPerson = new Person(); addedPerson.Save(); originalPeople.Add(addedPerson); IFormatter formatter = new BinaryFormatter(); MemoryStream memoryStream = new MemoryStream(); FixtureEnvironment.ClearBusinessObjectManager(); //---------------Assert PreConditions--------------- Assert.AreEqual(1, originalPeople.MarkedForDeleteBusinessObjects.Count); Assert.AreEqual(1, originalPeople.RemovedBusinessObjects.Count); Assert.AreEqual(1, originalPeople.AddedBusinessObjects.Count); Assert.AreEqual(3, originalPeople.PersistedBusinessObjects.Count); Assert.AreEqual(1, originalPeople.CreatedBusinessObjects.Count); Assert.AreEqual(3, originalPeople.Count); //---------------Execute Test ---------------------- formatter.Serialize(memoryStream, originalPeople); memoryStream.Seek(0, SeekOrigin.Begin); BusinessObjectCollection <Person> deserialisedPeople = (BusinessObjectCollection <Person>)formatter.Deserialize(memoryStream); //---------------Test Result ----------------------- Assert.AreEqual(originalPeople.Count, deserialisedPeople.Count); Assert.AreEqual(originalPeople.PersistedBusinessObjects.Count, deserialisedPeople.PersistedBusinessObjects.Count); Assert.AreEqual(originalPeople.CreatedBusinessObjects.Count, deserialisedPeople.CreatedBusinessObjects.Count); Assert.AreEqual(originalPeople.AddedBusinessObjects.Count, deserialisedPeople.AddedBusinessObjects.Count); Assert.AreEqual(originalPeople.RemovedBusinessObjects.Count, deserialisedPeople.RemovedBusinessObjects.Count); Assert.AreEqual(originalPeople.MarkedForDeleteBusinessObjects.Count, deserialisedPeople.MarkedForDeleteBusinessObjects.Count); AssertPersonsAreEqual(deserialisedPeople.MarkedForDeleteBusinessObjects[0], deletedPerson); AssertPersonsAreEqual(deserialisedPeople.RemovedBusinessObjects[0], removedPerson); AssertPersonsAreEqual(deserialisedPeople.AddedBusinessObjects[0], addedPerson); AssertPersonsAreEqual(deserialisedPeople.PersistedBusinessObjects[0], persistedPerson); AssertPersonsAreEqual(deserialisedPeople.CreatedBusinessObjects[0], createdPerson); }
public void SetupTestFixture() { FixtureEnvironment.SetupNewIsolatedBusinessObjectManager(); string dataFileDirectoryName = Path.GetDirectoryName(_dataFileName); if (!Directory.Exists(dataFileDirectoryName)) { Directory.CreateDirectory(dataFileDirectoryName); } }