CreateUnsavedValidVehicle() public static method

Creates a new unsaved Vehicle with a random value assigned to every property
public static CreateUnsavedValidVehicle ( ) : Vehicle
return TestProject.BO.Vehicle
コード例 #1
0
        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);
        }
コード例 #2
0
        [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);
        }
コード例 #3
0
        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);
            }
        }