Inheritance: BusinessObject
コード例 #1
0
        [Test]  // Ensures that the defaults have not been tampered
        public void Test_CreateVehicleWithDefaults()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            Vehicle vehicle = new Vehicle();

            //---------------Test Result -----------------------
                        Assert.IsNotNull(vehicle.VehicleID);
                        Assert.IsInstanceOf(vehicle.Props["VehicleID"].PropertyType, vehicle.VehicleID);
                        Assert.IsNull(vehicle.VehicleType);
                        Assert.IsNull(vehicle.MaxSpeed);
        }
コード例 #2
0
        [Test]  // Ensures that property setters in the code point to the correct property
        public void Test_PropertySettersUseCorrectPropertyNames()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            Vehicle vehicle = new Vehicle();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object valueForVehicleType = TestUtilsShared.GetRandomString();            
            vehicle.SetPropertyValue("VehicleType", valueForVehicleType);
            object valueForMaxSpeed = (double)TestUtilsShared.GetRandomInt();            
            vehicle.SetPropertyValue("MaxSpeed", valueForMaxSpeed);
            
            //---------------Test Result -----------------------
            Assert.AreEqual(valueForVehicleType, vehicle.VehicleType);
            Assert.AreEqual(valueForMaxSpeed, vehicle.MaxSpeed);
        }
コード例 #3
0
	    /// <summary>
        /// Creates a new unsaved Vehicle where all properties are null, except ID properties
        /// and those with default values.  If there are compulsory properties without
        /// defaults, saving the object will throw an exception.
        /// </summary>
		public static Vehicle CreateUnsavedDefaultVehicle()
		{
			Vehicle vehicle = new Vehicle();
			return vehicle;
		}
コード例 #4
0
        [Test]  // Ensures that gets and sets in the code refer to the same property
        public void Test_PropertyGetters()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            Vehicle vehicle = new Vehicle();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object valueForVehicleType = TestUtilsShared.GetRandomString();
            vehicle.VehicleType = (System.String) valueForVehicleType;
            object valueForMaxSpeed = (double)TestUtilsShared.GetRandomInt();
            vehicle.MaxSpeed = (System.Double) valueForMaxSpeed;
            
            //---------------Test Result -----------------------
            Assert.AreEqual(valueForVehicleType, vehicle.VehicleType);
            Assert.AreEqual(valueForMaxSpeed, vehicle.MaxSpeed);
        }
コード例 #5
0
        /// <summary>
        /// Creates a new unsaved Vehicle with a random value assigned to every property
        /// </summary>
		public static Vehicle CreateUnsavedValidVehicle()
		{
			Vehicle vehicle = new Vehicle();
			vehicle.MaxSpeed = (double)TestUtilsShared.GetRandomInt();
			return vehicle;
		}