CreateSavedVehicle() 공개 정적인 메소드

Creates a new saved Vehicle with a random value assigned to every property
public static CreateSavedVehicle ( ) : Vehicle
리턴 TestProjectNoDBSpecificProps.BO.Vehicle
예제 #1
0
        [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);
        }
예제 #2
0
        [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);
        }
예제 #3
0
        [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);
        }
예제 #4
0
        [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);
            }
        }