[Test] // Ensures that a saved class can be loaded public void Test_LoadVehicle() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- Vehicle vehicle = TestUtilsVehicle.CreateSavedVehicle(); //---------------Execute Test ---------------------- Vehicle loadedVehicle = Broker.GetBusinessObject <Vehicle>(vehicle.ID); //---------------Test Result ----------------------- Assert.AreEqual(vehicle.MaxSpeed, loadedVehicle.MaxSpeed); }
[Test] // Ensures that a class can be successfully saved public void Test_SaveVehicle() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- Vehicle vehicle = TestUtilsVehicle.CreateUnsavedValidVehicle(); //---------------Assert Precondition---------------- Assert.IsTrue(vehicle.Status.IsNew); BusinessObjectCollection <Vehicle> col = new BusinessObjectCollection <Vehicle>(); col.LoadAll(); Assert.AreEqual(0, col.Count); //---------------Execute Test ---------------------- vehicle.Save(); //---------------Test Result ----------------------- Assert.IsFalse(vehicle.Status.IsNew); col.LoadAll(); Assert.AreEqual(1, col.Count); }
[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------------------- Vehicle vehicle = TestUtilsVehicle.CreateSavedVehicle(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- vehicle.MaxSpeed = null; vehicle.Save(); //---------------Test Result ----------------------- BusinessObjectManager.Instance.ClearLoadedObjects(); GC.Collect(); TestUtilsShared.WaitForGC(); Vehicle retrievedVehicle = Broker.GetBusinessObject <Vehicle>(vehicle.ID); Assert.IsNull(retrievedVehicle.MaxSpeed); }
[Test] // Ensures that updates to property values are stored and can be retrieved public void Test_UpdateVehicle() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- Vehicle vehicle = TestUtilsVehicle.CreateSavedVehicle(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- object valueForMaxSpeed = (double)TestUtilsShared.GetRandomInt(); vehicle.MaxSpeed = (System.Double)valueForMaxSpeed; vehicle.Save(); //---------------Test Result ----------------------- BusinessObjectManager.Instance.ClearLoadedObjects(); GC.Collect(); TestUtilsShared.WaitForGC(); Vehicle retrievedVehicle = Broker.GetBusinessObject <Vehicle>(vehicle.ID); Assert.AreEqual(valueForMaxSpeed, retrievedVehicle.MaxSpeed); }
[Test] // Ensures that a class can be deleted public void Test_DeleteVehicle() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- Vehicle vehicle = TestUtilsVehicle.CreateSavedVehicle(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- vehicle.MarkForDelete(); vehicle.Save(); //---------------Test Result ----------------------- try { Vehicle retrievedVehicle = Broker.GetBusinessObject <Vehicle>(vehicle.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: Vehicle", ex.Message); } }