public static CreateUnsavedValidVehicle ( ) : |
||
Результат |
public void Test_ToString() { //---------------Set up test pack------------------- BORegistry.DataAccessor = new DataAccessorInMemory(); Vehicle vehicle = TestUtilsVehicle.CreateUnsavedValidVehicle(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- string toStringValue = vehicle.ToString(); //---------------Test Result ----------------------- Assert.Fail("Implement ToString() for Vehicle and refine this test"); //Assert.AreEqual(vehicle.SomeProperty, toStringValue); }
[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); }
public void Test_NotSettingCompulsoryPropertiesThrowsException() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- BORegistry.DataAccessor = new DataAccessorInMemory(); Vehicle vehicle = TestUtilsVehicle.CreateUnsavedValidVehicle(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- vehicle.VehicleID = null; try { vehicle.Save(); Assert.Fail("Should throw an exception when compulsory properties are null"); } //---------------Test Result ----------------------- catch (BusObjectInAnInvalidStateException ex) { StringAssert.Contains("Vehicle ID' is a compulsory field and has no value", ex.Message); } }