Inheritance: BusinessObject
        [Test]  // Ensures that the defaults have not been tampered
        public void Test_CreateSteeringWheelWithDefaults()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------

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

            //---------------Execute Test ----------------------
            SteeringWheel steeringWheel = new SteeringWheel();

            //---------------Test Result -----------------------
                        Assert.IsNotNull(steeringWheel.SteeringWheelID);
            Assert.IsInstanceOf(steeringWheel.Props["SteeringWheelID"].PropertyType, steeringWheel.SteeringWheelID);
                        Assert.IsNull(steeringWheel.CarID);
        }
Beispiel #2
0
        [Test] // Checks that BOs in a single relationship load correctly (no tampering with class defs)
        public void Test_LoadThroughSingleRelationship_SteeringWheel()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();

            SteeringWheel wheel = TestUtilsSteeringWheel.CreateSavedSteeringWheel();
            Car           car   = wheel.Car;

            TestProject.BO.SteeringWheel boForRelationshipSteeringWheel = car.SteeringWheel;

            BusinessObjectManager.Instance.ClearLoadedObjects();
            GC.Collect();
            TestUtilsShared.WaitForGC();
            //---------------Execute Test ----------------------
            TestProject.BO.SteeringWheel loadedRelatedBO =
                Broker.GetBusinessObject <TestProject.BO.SteeringWheel>(boForRelationshipSteeringWheel.ID);
            Car loadedCar = Broker.GetBusinessObject <Car>(car.ID);

            //---------------Test Result -----------------------
            Assert.AreEqual(boForRelationshipSteeringWheel, loadedCar.SteeringWheel);
            Assert.AreEqual(loadedRelatedBO, loadedCar.SteeringWheel);
            Assert.AreEqual(loadedRelatedBO, car.SteeringWheel);
        }
        [Test]  // Ensures that property setters in the code point to the correct property
        public void Test_PropertySettersUseCorrectPropertyNames()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            SteeringWheel steeringWheel = new SteeringWheel();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object valueForCarID = TestUtilsCar.CreateSavedCar().VehicleID;            
            steeringWheel.SetPropertyValue("CarID", valueForCarID);
            
            //---------------Test Result -----------------------
            Assert.AreEqual(valueForCarID, steeringWheel.CarID);
        }
        [Test]  // Ensures that gets and sets in the code refer to the same property
        public void Test_PropertyGetters()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            SteeringWheel steeringWheel = new SteeringWheel();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object valueForCarID = Guid.NewGuid();
            steeringWheel.CarID = (System.Guid) valueForCarID;
            
            //---------------Test Result -----------------------
            Assert.AreEqual(valueForCarID, steeringWheel.CarID);
        }
	    /// <summary>
        /// Creates a new unsaved SteeringWheel 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 SteeringWheel CreateUnsavedDefaultSteeringWheel()
		{
			SteeringWheel steeringWheel = new SteeringWheel();
			return steeringWheel;
		}
        /// <summary>
        /// Creates a new unsaved SteeringWheel with a random value assigned to every property
        /// </summary>
		public static SteeringWheel CreateUnsavedValidSteeringWheel()
		{
			SteeringWheel steeringWheel = new SteeringWheel();
            steeringWheel.Car = TestUtilsCar.CreateSavedCar();
			return steeringWheel;
		}