예제 #1
0
        public void Test_BusinessObjectAuthorisation_AllowCreate_False()
        {
            //---------------Set up test pack-------------------
            IBusinessObjectAuthorisation authorisationStub = new AuthorisationStub();
            Customer customer = new Customer();
            customer.SetAuthorisation(authorisationStub);
            //---------------Assert Precondition----------------
            Assert.IsFalse(authorisationStub.IsAuthorised(BusinessObjectActions.CanCreate));
            //---------------Execute Test ----------------------
            string message;
            bool isCreatable = customer.IsCreatable(out message);

            //---------------Test Result -----------------------
            Assert.IsFalse(isCreatable);
            StringAssert.Contains("The logged on user", message);
            StringAssert.Contains("is not authorised to create ", message);
        }
예제 #2
0
        public void Test_BusinessObjectAuthorisation_AllowCreate()
        {
            //---------------Set up test pack-------------------
            IBusinessObjectAuthorisation authorisationStub = new AuthorisationStub();
            authorisationStub.AddAuthorisedRole("A Role", BusinessObjectActions.CanCreate);
            Customer customer = new Customer();
            customer.SetAuthorisation(authorisationStub);

            //---------------Assert Precondition----------------
            Assert.IsTrue(authorisationStub.IsAuthorised(BusinessObjectActions.CanCreate));

            //---------------Execute Test ----------------------
            string message;
            bool isCreatable = customer.IsCreatable(out message);

            //---------------Test Result -----------------------
            Assert.IsTrue(isCreatable);
            Assert.AreEqual("", message);
        }