public void Test_BusinessObjectAuthorisation_AllowRead_False() { //---------------Set up test pack------------------- IBusinessObjectAuthorisation authorisationStub = new AuthorisationStub(); Customer customer = new Customer(); customer.SetAuthorisation(authorisationStub); //---------------Assert Precondition---------------- Assert.IsFalse(authorisationStub.IsAuthorised(BusinessObjectActions.CanRead)); //---------------Execute Test ---------------------- string message; bool isReadable = customer.IsReadable(out message); //---------------Test Result ----------------------- Assert.IsFalse(isReadable); StringAssert.Contains("The logged on user", message); StringAssert.Contains("is not authorised to read ", 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); }