public void Test_NotLockedIfLockDurationExceeded() { //---------------Set up test pack------------------- ContactPersonPessimisticLockingDB cp = CreateSavedContactPersonPessimisticLocking(); IConcurrencyControl concurrCntrl = cp.ConcurrencyControl(); //Create Lock concurrCntrl.CheckConcurrencyBeforeBeginEditing(); int lockDuration = 15; UpdateDatabaseLockAsExpired(lockDuration); //---------------Execute Test ---------------------- concurrCntrl.CheckConcurrencyBeforeBeginEditing(); //---------------Test Result ----------------------- //Should not raise an error since the lock duration has been exceeded. }
public void Test_ThrowErrorIfCheckConcurrencyBeforeEditingTwice() { //---------------Set up test pack------------------- ContactPersonPessimisticLockingDB cp = CreateSavedContactPersonPessimisticLocking(); //---------------Execute Test ---------------------- IConcurrencyControl concurrCntrl = cp.ConcurrencyControl(); concurrCntrl.CheckConcurrencyBeforeBeginEditing(); try { concurrCntrl.CheckConcurrencyBeforeBeginEditing(); Assert.Fail(); } //---------------Test Result ----------------------- catch (BusObjPessimisticConcurrencyControlException ex) { Assert.IsTrue( ex.Message.Contains( "You cannot begin edits on the 'ContactPersonPessimisticLockingDB', as another user has started edits and therefore locked to this record.")); } }
public void Test_ThrowErrorIfObjectDeletedPriorToBeginEdits() { //---------------Set up test pack------------------- ContactPersonPessimisticLockingDB cp = CreateSavedContactPersonPessimisticLocking(); //---------------Execute Test ---------------------- ContactPerson.DeleteAllContactPeople(); try { IConcurrencyControl concurrCntrl = cp.ConcurrencyControl(); concurrCntrl.CheckConcurrencyBeforeBeginEditing(); Assert.Fail(); } //---------------Test Result ----------------------- catch (BusObjDeleteConcurrencyControlException ex) { Assert.IsTrue( ex.Message.Contains( "You cannot save the changes to 'ContactPersonPessimisticLockingDB', as another user has deleted the record")); } }