public void Test_DeleteBO_Fail_AllowDelete_False() { //---------------Set up test pack------------------- MyBoAuthenticationStub.LoadDefaultClassDef(); IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanDelete_False(); MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub(); myBoStub.SetAuthorisation(authorisationStub); //---------------Assert Precondition---------------- Assert.IsFalse(authorisationStub.IsAuthorised(myBoStub, BusinessObjectActions.CanDelete)); //---------------Execute Test ---------------------- try { myBoStub.MarkForDelete(); Assert.Fail("expected Err"); } //---------------Test Result ----------------------- catch (BusObjDeleteException ex) { StringAssert.Contains("The logged on user", ex.Message); StringAssert.Contains("is not authorised to delete ", ex.Message); } }
public void Test_DeleteBO_AllowDelete_True() { //---------------Set up test pack------------------- MyBoAuthenticationStub.LoadDefaultClassDef(); IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanDelete_True(); MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub(); myBoStub.SetAuthorisation(authorisationStub); myBoStub.Save(); //---------------Assert Precondition---------------- Assert.IsTrue(authorisationStub.IsAuthorised(myBoStub, BusinessObjectActions.CanDelete)); Assert.IsFalse(myBoStub.Status.IsNew); //---------------Execute Test ---------------------- myBoStub.MarkForDelete(); myBoStub.Save(); //---------------Test Result ----------------------- Assert.IsTrue(myBoStub.Status.IsDeleted); Assert.IsTrue(myBoStub.Status.IsNew); }