[Test] // Checks that deleting this instance has no effect in the related class public void Test_SingleRelationshipDeletion_DoNothing_Car() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- SteeringWheel steeringWheel = TestUtilsSteeringWheel.CreateSavedSteeringWheel(); TestProject.BO.Car boForRelationshipCar = TestUtilsCar.CreateSavedCar(); steeringWheel.Car = boForRelationshipCar; steeringWheel.Save(); //---------------Assert Preconditions--------------- IRelationshipDef relationshipDef = ClassDef.Get <SteeringWheel>().RelationshipDefCol["Car"]; Assert.AreEqual(DeleteParentAction.DoNothing, relationshipDef.DeleteParentAction); //---------------Execute Test ---------------------- steeringWheel.MarkForDelete(); steeringWheel.Save(); //---------------Execute Test ---------------------- BusinessObjectManager.Instance.ClearLoadedObjects(); GC.Collect(); TestUtilsShared.WaitForGC(); try { Broker.GetBusinessObject <SteeringWheel>(steeringWheel.ID); Assert.Fail("BO should no longer exist and exception should be thrown"); } catch (BusObjDeleteConcurrencyControlException ex) { StringAssert.Contains("There are no records in the database for the Class: SteeringWheel", ex.Message); } TestProject.BO.Car relatedBO = Broker.GetBusinessObject <TestProject.BO.Car>(boForRelationshipCar.ID); Assert.AreEqual(relatedBO.ID.ToString(), boForRelationshipCar.ID.ToString()); }
[Test] // Ensures that a saved class can be loaded public void Test_LoadSteeringWheel() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- SteeringWheel steeringWheel = TestUtilsSteeringWheel.CreateSavedSteeringWheel(); //---------------Execute Test ---------------------- SteeringWheel loadedSteeringWheel = Broker.GetBusinessObject <SteeringWheel>(steeringWheel.ID); //---------------Test Result ----------------------- Assert.AreEqual(steeringWheel.SteeringWheelID, loadedSteeringWheel.SteeringWheelID); Assert.AreEqual(steeringWheel.CarID, loadedSteeringWheel.CarID); }
[Test] // Checks that BOs in a single relationship load correctly (no tampering with class defs) public void Test_LoadThroughSingleRelationship_Car() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- BORegistry.DataAccessor = new DataAccessorInMemory(); SteeringWheel steeringWheel = TestUtilsSteeringWheel.CreateSavedSteeringWheel(); TestProject.BO.Car boForRelationshipCar = steeringWheel.Car; BusinessObjectManager.Instance.ClearLoadedObjects(); GC.Collect(); TestUtilsShared.WaitForGC(); //---------------Execute Test ---------------------- TestProject.BO.Car loadedRelatedBO = Broker.GetBusinessObject <TestProject.BO.Car>(boForRelationshipCar.ID); SteeringWheel loadedSteeringWheel = Broker.GetBusinessObject <SteeringWheel>(steeringWheel.ID); //---------------Test Result ----------------------- Assert.AreEqual(boForRelationshipCar, loadedSteeringWheel.Car); Assert.AreEqual(loadedRelatedBO, loadedSteeringWheel.Car); Assert.AreEqual(loadedRelatedBO, steeringWheel.Car); }
[Test] // Makes sure there are no non-null rules in the database that don't have corresponding compulsory rules public void Test_SetPropertyValue_Null() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- SteeringWheel steeringWheel = TestUtilsSteeringWheel.CreateSavedSteeringWheel(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- steeringWheel.CarID = null; steeringWheel.Save(); //---------------Test Result ----------------------- BusinessObjectManager.Instance.ClearLoadedObjects(); GC.Collect(); TestUtilsShared.WaitForGC(); SteeringWheel retrievedSteeringWheel = Broker.GetBusinessObject <SteeringWheel>(steeringWheel.ID); Assert.IsNull(retrievedSteeringWheel.CarID); }
[Test] // Ensures that updates to property values are stored and can be retrieved public void Test_UpdateSteeringWheel() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- SteeringWheel steeringWheel = TestUtilsSteeringWheel.CreateSavedSteeringWheel(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- object valueForCarID = Guid.NewGuid(); steeringWheel.CarID = (System.Guid)valueForCarID; steeringWheel.Save(); //---------------Test Result ----------------------- BusinessObjectManager.Instance.ClearLoadedObjects(); GC.Collect(); TestUtilsShared.WaitForGC(); SteeringWheel retrievedSteeringWheel = Broker.GetBusinessObject <SteeringWheel>(steeringWheel.ID); Assert.AreEqual(valueForCarID, retrievedSteeringWheel.CarID); }
[Test] // Ensures that a class can be deleted public void Test_DeleteSteeringWheel() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- SteeringWheel steeringWheel = TestUtilsSteeringWheel.CreateSavedSteeringWheel(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- steeringWheel.MarkForDelete(); steeringWheel.Save(); //---------------Test Result ----------------------- try { SteeringWheel retrievedSteeringWheel = Broker.GetBusinessObject <SteeringWheel>(steeringWheel.ID); Assert.Fail("expected Err"); } 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: SteeringWheel", ex.Message); } }