CreateSavedDriver() public static method

Creates a new saved Driver with a random value assigned to every property
public static CreateSavedDriver ( ) : Driver
return TestProject.BO.Driver
Esempio n. 1
0
        [Test]  // Checks that deleting this instance has no effect in the related class
        public void Test_SingleRelationshipDeletion_DoNothing_Car()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            Driver driver = TestUtilsDriver.CreateSavedDriver();

            TestProject.BO.Car boForRelationshipCar = TestUtilsCar.CreateSavedCar();
            driver.Car = boForRelationshipCar;
            driver.Save();

            //---------------Assert Preconditions---------------
            IRelationshipDef relationshipDef = ClassDef.Get <Driver>().RelationshipDefCol["Car"];

            Assert.AreEqual(DeleteParentAction.DoNothing, relationshipDef.DeleteParentAction);
            //---------------Execute Test ----------------------
            driver.MarkForDelete();
            driver.Save();
            //---------------Execute Test ----------------------
            BusinessObjectManager.Instance.ClearLoadedObjects();
            GC.Collect();
            TestUtilsShared.WaitForGC();

            try
            {
                Broker.GetBusinessObject <Driver>(driver.ID);
                Assert.Fail("BO should no longer exist and exception should be thrown");
            }
            catch (BusObjDeleteConcurrencyControlException ex)
            {
                StringAssert.Contains("There are no records in the database for the Class: Driver", ex.Message);
            }

            TestProject.BO.Car relatedBO = Broker.GetBusinessObject <TestProject.BO.Car>(boForRelationshipCar.ID);
            Assert.AreEqual(relatedBO.ID.ToString(), boForRelationshipCar.ID.ToString());
        }
Esempio n. 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-------------------
            Driver driver = TestUtilsDriver.CreateSavedDriver();

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

            //---------------Execute Test ----------------------
            driver.DriverName   = null;
            driver.Age          = null;
            driver.DOB          = null;
            driver.LicenseRaing = null;
            driver.CarID        = null;
            driver.Save();

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

            Assert.IsNull(retrievedDriver.DriverName);
            Assert.IsNull(retrievedDriver.Age);
            Assert.IsNull(retrievedDriver.DOB);
            Assert.IsNull(retrievedDriver.LicenseRaing);
            Assert.IsNull(retrievedDriver.CarID);
        }
Esempio n. 3
0
        [Test]  // Ensures that a saved class can be loaded
        public void Test_LoadDriver()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            Driver driver = TestUtilsDriver.CreateSavedDriver();

            //---------------Execute Test ----------------------
            Driver loadedDriver = Broker.GetBusinessObject <Driver>(driver.ID);

            //---------------Test Result -----------------------
            Assert.AreEqual(driver.DriverID, loadedDriver.DriverID);
            Assert.AreEqual(driver.DriverName, loadedDriver.DriverName);
            Assert.AreEqual(driver.Age, loadedDriver.Age);
            Assert.AreEqual(driver.DOB, loadedDriver.DOB);
            Assert.AreEqual(driver.LicenseRaing, loadedDriver.LicenseRaing);
            Assert.AreEqual(driver.CarID, loadedDriver.CarID);
        }
Esempio n. 4
0
        [Test]  // Checks that BOs in a single relationship load correctly (no tampering with class defs)
        public void Test_LoadThroughSingleRelationship_Car()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            Driver driver = TestUtilsDriver.CreateSavedDriver();

            TestProject.BO.Car boForRelationshipCar = driver.Car;

            BusinessObjectManager.Instance.ClearLoadedObjects();
            GC.Collect();
            TestUtilsShared.WaitForGC();
            //---------------Execute Test ----------------------
            TestProject.BO.Car loadedRelatedBO = Broker.GetBusinessObject <TestProject.BO.Car>(boForRelationshipCar.ID);
            Driver             loadedDriver    = Broker.GetBusinessObject <Driver>(driver.ID);

            //---------------Test Result -----------------------
            Assert.AreEqual(boForRelationshipCar, loadedDriver.Car);
            Assert.AreEqual(loadedRelatedBO, loadedDriver.Car);
            Assert.AreEqual(loadedRelatedBO, driver.Car);
        }
Esempio n. 5
0
        [Test]  // Ensures that updates to property values are stored and can be retrieved
        public void Test_UpdateDriver()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            Driver 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();

            driver.LicenseRaing = (System.Double)valueForLicenseRaing;
            object valueForCarID = Guid.NewGuid();

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

            //---------------Test Result -----------------------
            BusinessObjectManager.Instance.ClearLoadedObjects();
            GC.Collect();
            TestUtilsShared.WaitForGC();
            Driver 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);
        }
Esempio n. 6
0
        [Test]  // Ensures that a class can be deleted
        public void Test_DeleteDriver()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            Driver driver = TestUtilsDriver.CreateSavedDriver();

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

            //---------------Execute Test ----------------------
            driver.MarkForDelete();
            driver.Save();
            //---------------Test Result -----------------------
            try
            {
                Driver retrievedDriver = Broker.GetBusinessObject <Driver>(driver.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: Driver", ex.Message);
            }
        }