public void TestLockingVersionNumber_DoesNotCauseProblemsWithMultipleSaves()
        {
            //---------------Set up test pack-------------------
            //Create object in DB

            ContactPersonOptimisticLockingVersionNumberDB.LoadDefaultClassDef();
            ContactPersonOptimisticLockingVersionNumberDB contactPerson = new ContactPersonOptimisticLockingVersionNumberDB();

            contactPerson.Surname = Guid.NewGuid().ToString();
            AddObjectToDelete(contactPerson);
            contactPerson.Save();
            //---------------Execute Test ----------------------
            //Edit first object and persist to the database.
            contactPerson.Surname = Guid.NewGuid().ToString();
            contactPerson.Save();
        }
        public void TestDeleteObjectPriorToUpdatesConcurrencyControl()
        {
            //----------SETUP TEST PACK--------------------------
            ContactPersonOptimisticLockingVersionNumberDB contactPersonDeleteConcurrency
                = CreateSavedCntactPersonOptimisticLockingVersionNumberDB();

            //Clear object manager
            FixtureEnvironment.ClearBusinessObjectManager();
            //Load second object from DB

            ContactPersonOptimisticLockingVersionNumberDB contactPerson2
                = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <ContactPersonOptimisticLockingVersionNumberDB>(contactPersonDeleteConcurrency.ID);

            //---------Run TEST ---------------------------------
            contactPersonDeleteConcurrency.MarkForDelete();
            contactPerson2.Surname = "New Surname 2";
            contactPersonDeleteConcurrency.Save();
            try
            {
                contactPerson2.Save();
                Assert.Fail();
            }
            //--------Check Result --------------------------------
            catch (BusObjDeleteConcurrencyControlException ex)
            {
                Assert.IsTrue(ex.Message.Contains("You cannot save the changes to 'ContactPersonOptimisticLockingVersionNumberDB', as another user has deleted the record"));
            }
        }
        public void TestLockingVersionNumber_OnBeginEdit()
        {
            //---------------Set up test pack-------------------
            //Create object in DB

            ContactPersonOptimisticLockingVersionNumberDB.LoadDefaultClassDef();
            ContactPersonOptimisticLockingVersionNumberDB contactPerson = new ContactPersonOptimisticLockingVersionNumberDB
                                                                              {Surname = Guid.NewGuid().ToString()};
            AddObjectToDelete(contactPerson);
            contactPerson.Save();
            //Clear object manager
            FixtureEnvironment.ClearBusinessObjectManager();
            //Load second object from DB
            ContactPersonOptimisticLockingVersionNumberDB duplicateContactPerson =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject<ContactPersonOptimisticLockingVersionNumberDB>(contactPerson.ID);
            AddObjectToDelete(duplicateContactPerson);

            //---------------Execute Test ----------------------
            //Edit first object and persist to the database.
            contactPerson.Surname = Guid.NewGuid().ToString();
            contactPerson.Save();
            //Begin Edit on second object
            try
            {
                duplicateContactPerson.FirstName = Guid.NewGuid().ToString();
                Assert.Fail("Should throw error");
            }    
                //---------------Test Result -----------------------
                //Raise Exception that the object has been edited since 
                // the user last edited.
            catch(BusObjBeginEditConcurrencyControlException ex)
            {
                Assert.IsTrue(ex.Message.Contains("You cannot Edit 'ContactPersonOptimisticLockingVersionNumberDB', as another user has edited this record"));
            }
        }
        public void TestLockingVersionNumber_DoesNotCauseProblemsWithMultipleSaves()
        {
            //---------------Set up test pack-------------------
            //Create object in DB

            ContactPersonOptimisticLockingVersionNumberDB.LoadDefaultClassDef();
            ContactPersonOptimisticLockingVersionNumberDB contactPerson = new ContactPersonOptimisticLockingVersionNumberDB();
            contactPerson.Surname = Guid.NewGuid().ToString();
            AddObjectToDelete(contactPerson);
            contactPerson.Save();
            //---------------Execute Test ----------------------
            //Edit first object and persist to the database.
            contactPerson.Surname = Guid.NewGuid().ToString();
            contactPerson.Save();

        }
        private static ContactPersonOptimisticLockingVersionNumberDB CreateSavedCntactPersonOptimisticLockingVersionNumberDB()
        {
            ContactPersonOptimisticLockingVersionNumberDB.LoadDefaultClassDef();
            ContactPersonOptimisticLockingVersionNumberDB contactPersonOptimisticLockingVersionNumberDB;

            contactPersonOptimisticLockingVersionNumberDB         = new ContactPersonOptimisticLockingVersionNumberDB();
            contactPersonOptimisticLockingVersionNumberDB.Surname = Guid.NewGuid().ToString();
            contactPersonOptimisticLockingVersionNumberDB.Save();
            AddObjectToDelete(contactPersonOptimisticLockingVersionNumberDB);
            return(contactPersonOptimisticLockingVersionNumberDB);
        }
        public void TestLockingVersionNumber_OnBeginEdit()
        {
            //---------------Set up test pack-------------------
            //Create object in DB

            ContactPersonOptimisticLockingVersionNumberDB.LoadDefaultClassDef();
            ContactPersonOptimisticLockingVersionNumberDB contactPerson = new ContactPersonOptimisticLockingVersionNumberDB
            {
                Surname = Guid.NewGuid().ToString()
            };

            AddObjectToDelete(contactPerson);
            contactPerson.Save();
            //Clear object manager
            FixtureEnvironment.ClearBusinessObjectManager();
            //Load second object from DB
            ContactPersonOptimisticLockingVersionNumberDB duplicateContactPerson =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <ContactPersonOptimisticLockingVersionNumberDB>(contactPerson.ID);

            AddObjectToDelete(duplicateContactPerson);

            //---------------Execute Test ----------------------
            //Edit first object and persist to the database.
            contactPerson.Surname = Guid.NewGuid().ToString();
            contactPerson.Save();
            //Begin Edit on second object
            try
            {
                duplicateContactPerson.FirstName = Guid.NewGuid().ToString();
                Assert.Fail("Should throw error");
            }
            //---------------Test Result -----------------------
            //Raise Exception that the object has been edited since
            // the user last edited.
            catch (BusObjBeginEditConcurrencyControlException ex)
            {
                Assert.IsTrue(ex.Message.Contains("You cannot Edit 'ContactPersonOptimisticLockingVersionNumberDB', as another user has edited this record"));
            }
        }
 private static ContactPersonOptimisticLockingVersionNumberDB CreateSavedCntactPersonOptimisticLockingVersionNumberDB()
 {
     ContactPersonOptimisticLockingVersionNumberDB.LoadDefaultClassDef();
     ContactPersonOptimisticLockingVersionNumberDB contactPersonOptimisticLockingVersionNumberDB;
     contactPersonOptimisticLockingVersionNumberDB = new ContactPersonOptimisticLockingVersionNumberDB();
     contactPersonOptimisticLockingVersionNumberDB.Surname = Guid.NewGuid().ToString();
     contactPersonOptimisticLockingVersionNumberDB.Save();
     AddObjectToDelete(contactPersonOptimisticLockingVersionNumberDB);
     return contactPersonOptimisticLockingVersionNumberDB;
 }