Ejemplo n.º 1
0
        [Test]  // Ensures that updates to property values are stored and can be retrieved
        public void Test_UpdateCar()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            Car car = TestUtilsCar.CreateSavedCar();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object valueForMake = TestUtilsShared.GetRandomString();

            car.Make = (System.String)valueForMake;
            object valueForModel = TestUtilsShared.GetRandomString();

            car.Model = (System.String)valueForModel;
            object valueForMaxSpeed = (double)TestUtilsShared.GetRandomInt();

            car.MaxSpeed = (System.Double)valueForMaxSpeed;
            car.Save();

            //---------------Test Result -----------------------
            BusinessObjectManager.Instance.ClearLoadedObjects();
            GC.Collect();
            TestUtilsShared.WaitForGC();
            Car retrievedCar = Broker.GetBusinessObject <Car>(car.ID);

            Assert.AreEqual(valueForMake, retrievedCar.Make);
            Assert.AreEqual(valueForModel, retrievedCar.Model);
            Assert.AreEqual(valueForMaxSpeed, retrievedCar.MaxSpeed);
        }
Ejemplo n.º 2
0
        [Test]  // Ensures that property setters in the code point to the correct property
        public void Test_PropertySettersUseCorrectPropertyNames()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            var driver = new Driver();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object valueForDriverName = TestUtilsShared.GetRandomString();

            driver.SetPropertyValue("DriverName", valueForDriverName);
            object valueForAge = TestUtilsShared.GetRandomInt();

            driver.SetPropertyValue("Age", valueForAge);
            object valueForDOB = TestUtilsShared.GetRandomDate();

            driver.SetPropertyValue("DOB", valueForDOB);
            object valueForLicenseRaing = (double)TestUtilsShared.GetRandomInt();

            driver.SetPropertyValue("LicenseRaing", valueForLicenseRaing);

            //---------------Test Result -----------------------
            Assert.AreEqual(valueForDriverName, driver.DriverName);
            Assert.AreEqual(valueForAge, driver.Age);
            Assert.AreEqual(valueForDOB, driver.DOB);
            Assert.AreEqual(valueForLicenseRaing, driver.LicenseRaing);
        }
Ejemplo n.º 3
0
        [Test]  // Ensures that gets and sets in the code refer to the same property
        public void Test_PropertyGetters()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            var driver = new Driver();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object valueForDriverName = TestUtilsShared.GetRandomString();

            driver.DriverName = (System.String)valueForDriverName;
            object valueForAge = TestUtilsShared.GetRandomInt();

            driver.Age = (System.Int32)valueForAge;
            object valueForDOB = TestUtilsShared.GetRandomDate();

            driver.DOB = (System.DateTime)valueForDOB;
            object valueForLicenseRaing = (double)TestUtilsShared.GetRandomInt();

// ReSharper disable PossibleInvalidCastException
            driver.LicenseRaing = (System.Double)valueForLicenseRaing;
// ReSharper restore PossibleInvalidCastException
            object valueForCarID = Guid.NewGuid();

            driver.CarID = (System.Guid)valueForCarID;

            //---------------Test Result -----------------------
            Assert.AreEqual(valueForDriverName, driver.DriverName);
            Assert.AreEqual(valueForAge, driver.Age);
            Assert.AreEqual(valueForDOB, driver.DOB);
            Assert.AreEqual(valueForLicenseRaing, driver.LicenseRaing);
            Assert.AreEqual(valueForCarID, driver.CarID);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new unsaved Car with a random value assigned to every property
        /// </summary>
        public static Car CreateUnsavedValidCar()
        {
            Car car = new Car();

            car.Make     = TestUtilsShared.GetRandomString();
            car.Model    = TestUtilsShared.GetRandomString();
            car.MaxSpeed = (double)TestUtilsShared.GetRandomInt();
            return(car);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new unsaved Driver with a random value assigned to every property
        /// </summary>
        public static Driver CreateUnsavedValidDriver()
        {
            Driver driver = new Driver();

            driver.DriverName   = TestUtilsShared.GetRandomString();
            driver.Age          = TestUtilsShared.GetRandomInt();
            driver.DOB          = TestUtilsShared.GetRandomDate();
            driver.LicenseRaing = (double)TestUtilsShared.GetRandomInt();
            driver.Car          = TestUtilsCar.CreateSavedCar();
            return(driver);
        }
Ejemplo n.º 6
0
        [Test]  // Ensures that property setters in the code point to the correct property
        public void Test_PropertySettersUseCorrectPropertyNames()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            Car car = new Car();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object valueForMake = TestUtilsShared.GetRandomString();

            car.SetPropertyValue("Make", valueForMake);
            object valueForModel = TestUtilsShared.GetRandomString();

            car.SetPropertyValue("Model", valueForModel);

            //---------------Test Result -----------------------
            Assert.AreEqual(valueForMake, car.Make);
            Assert.AreEqual(valueForModel, car.Model);
        }
Ejemplo n.º 7
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.GetPropertyValue("VehicleType"));
            Assert.AreEqual(valueForMaxSpeed, vehicle.MaxSpeed);
        }
Ejemplo n.º 8
0
        [Test]  // Ensures that updates to property values are stored and can be retrieved
        public void Test_UpdateDriver()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            var driver = TestUtilsDriver.CreateSavedDriver();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object valueForDriverName = TestUtilsShared.GetRandomString();

            driver.DriverName = (System.String)valueForDriverName;
            object valueForAge = TestUtilsShared.GetRandomInt();

            driver.Age = (System.Int32)valueForAge;
            object valueForDOB = TestUtilsShared.GetRandomDate();

            driver.DOB = (System.DateTime)valueForDOB;
            object valueForLicenseRaing = (double)TestUtilsShared.GetRandomInt();

// ReSharper disable PossibleInvalidCastException
            driver.LicenseRaing = (System.Double)valueForLicenseRaing;
// ReSharper restore PossibleInvalidCastException
            object valueForCarID = Guid.NewGuid();

            driver.CarID = (System.Guid)valueForCarID;
            driver.Save();

            //---------------Test Result -----------------------
            BusinessObjectManager.Instance.ClearLoadedObjects();
            GC.Collect();
            TestUtilsShared.WaitForGC();
            var retrievedDriver =
                Broker.GetBusinessObject <Driver>(driver.ID);

            Assert.AreEqual(valueForDriverName, retrievedDriver.DriverName);
            Assert.AreEqual(valueForAge, retrievedDriver.Age);
            Assert.AreEqual(valueForDOB, retrievedDriver.DOB);
            Assert.AreEqual(valueForLicenseRaing, retrievedDriver.LicenseRaing);
            Assert.AreEqual(valueForCarID, retrievedDriver.CarID);
        }
Ejemplo n.º 9
0
        [Test]  // Ensures that gets and sets in the code refer to the same property
        public void Test_PropertyGetters()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            Car car = new Car();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object valueForMake = TestUtilsShared.GetRandomString();

            car.Make = (System.String)valueForMake;
            object valueForModel = TestUtilsShared.GetRandomString();

            car.Model = (System.String)valueForModel;
            object valueForMaxSpeed = (double)TestUtilsShared.GetRandomInt();

            car.MaxSpeed = (System.Double)valueForMaxSpeed;

            //---------------Test Result -----------------------
            Assert.AreEqual(valueForMake, car.Make);
            Assert.AreEqual(valueForModel, car.Model);
            Assert.AreEqual(valueForMaxSpeed, car.MaxSpeed);
        }