public SetAuthorisation ( IBusinessObjectAuthorisation authorisation ) : void | ||
authorisation | IBusinessObjectAuthorisation | |
return | void |
public void Test_BusinessObjectAuthorisation_AllowDelete_False() { //---------------Set up test pack------------------- IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanDelete_False(); Customer customer = new Customer(); customer.SetAuthorisation(authorisationStub); //---------------Assert Precondition---------------- Assert.IsFalse(authorisationStub.IsAuthorised(BusinessObjectActions.CanDelete)); //---------------Execute Test ---------------------- string message; bool isDeletable = customer.IsDeletable(out message); //---------------Test Result ----------------------- Assert.IsFalse(isDeletable); StringAssert.Contains("The logged on user", message); StringAssert.Contains("is not authorised to delete ", message); }
public void Test_BusinessObjectAuthorisation_AllowDelete() { //---------------Set up test pack------------------- IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanDelete_True(); Customer customer = new Customer(); customer.SetAuthorisation(authorisationStub); //---------------Assert Precondition---------------- Assert.IsTrue(authorisationStub.IsAuthorised(BusinessObjectActions.CanDelete)); //---------------Execute Test ---------------------- string message; bool isDeletable = customer.IsDeletable(out message); //---------------Test Result ----------------------- Assert.IsTrue(isDeletable); Assert.AreEqual("", message); }
public void Test_BusinessObjectAuthorisation_AllowRead() { //---------------Set up test pack------------------- IBusinessObjectAuthorisation authorisationStub = new AuthorisationStub(); authorisationStub.AddAuthorisedRole("A Role", BusinessObjectActions.CanRead); Customer customer = new Customer(); customer.SetAuthorisation(authorisationStub); //---------------Assert Precondition---------------- Assert.IsTrue(authorisationStub.IsAuthorised(BusinessObjectActions.CanRead)); //---------------Execute Test ---------------------- string message; bool isReadable = customer.IsReadable(out message); //---------------Test Result ----------------------- Assert.IsTrue(isReadable); Assert.AreEqual("", message); }
public void Test_DeleteBO_Fail_AllowDelete_False() { //---------------Set up test pack------------------- IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanDelete_False(); Customer customer = new Customer(); customer.SetAuthorisation(authorisationStub); //---------------Assert Precondition---------------- Assert.IsFalse(authorisationStub.IsAuthorised(BusinessObjectActions.CanDelete)); //---------------Execute Test ---------------------- try { customer.Delete(); 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); } }