/// <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);
        }
        [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);
        }
Beispiel #3
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);
        }
Beispiel #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-------------------
            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);
        }
Beispiel #5
0
        public static DateTime GetRandomDate(string min, string max)
        {
            DateTime start = DateTime.Parse(min);

            int range = (DateTime.Parse(max) - start).Days;

            return(start.AddDays(TestUtilsShared.GetRandomInt(range)));
        }
Beispiel #6
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);
        }
Beispiel #7
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);
        }
        [Test]  // Ensures that property getters in the code point to the correct property
        public void Test_PropertyGettersUseCorrectPropertyNames()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            Vehicle vehicle = new Vehicle();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object valueForMaxSpeed = (double)TestUtilsShared.GetRandomInt();

            vehicle.MaxSpeed = (System.Double)valueForMaxSpeed;

            //---------------Test Result -----------------------
            Assert.AreEqual(valueForMaxSpeed, vehicle.GetPropertyValue("MaxSpeed"));
        }
Beispiel #9
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);
        }
        [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);
        }
        [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);
        }
Beispiel #12
0
 /// <summary>
 /// Takes a lookup list generated by Habanero and randomly selects a value
 /// from the list
 /// </summary>
 public static object GetRandomLookupListValue(Dictionary <string, string> lookupList)
 {
     string[] values = new string[lookupList.Count];
     lookupList.Values.CopyTo(values, 0);
     return(values[TestUtilsShared.GetRandomInt(0, values.Length - 1)]);
 }