Test.CustomerExample.BO.AuthorisationStub.IsAuthorised C# (CSharp) Method

IsAuthorised() public method

Whether the user is authorised to perform this action or not. This is an implementation of the IBusinessObjectAuthorisation method.
public IsAuthorised ( BusinessObjectActions actionToPerform ) : bool
actionToPerform BusinessObjectActions
return bool
        public bool IsAuthorised(BusinessObjectActions actionToPerform)
        {
            return (actionsAllowed.Contains(actionToPerform));
        }
    }

Usage Example

        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);
        }
All Usage Examples Of Test.CustomerExample.BO.AuthorisationStub::IsAuthorised