Пример #1
0
        public void Test_BO_GetPropertyValue_Fail_AllowRead_False()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBOPropAuthorisation propAuthorisationStub = GetPropAuthorisationStub_CanRead_False();

            MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub();
            BOProp prop1 = (BOProp)myBoStub.Props["Prop1"];

            prop1.SetAuthorisationRules(propAuthorisationStub);

            //---------------Assert Precondition----------------
            Assert.IsFalse(propAuthorisationStub.IsAuthorised(prop1, BOPropActions.CanRead));
            string message;

            Assert.IsFalse(prop1.IsReadable(out message));

            //---------------Execute Test ----------------------
            try
            {
                myBoStub.GetPropertyValue("Prop1");
                Assert.Fail("expected Err");
            }
            //---------------Test Result -----------------------
            catch (BOPropReadException ex)
            {
                StringAssert.Contains("The logged on user  is not authorised to read the Prop1 ", ex.Message);
            }
        }
Пример #2
0
        public void Test_GetValue_AllowRead_True()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBOPropAuthorisation   propAuthorisationStub = GetPropAuthorisationStub_CanRead_True();
            MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub();
            BOProp prop1 = (BOProp)myBoStub.Props["Prop1"];

            prop1.SetAuthorisationRules(propAuthorisationStub);
            myBoStub.Save();

            //---------------Assert Precondition----------------
            Assert.IsTrue(propAuthorisationStub.IsAuthorised(prop1, BOPropActions.CanRead));
            string message;

            Assert.IsTrue(prop1.IsReadable(out message));

            //---------------Execute Test ----------------------
            const string newPropValue = "1112";

            prop1.Value = newPropValue;

            //---------------Test Result -----------------------
            Assert.IsTrue(prop1.IsDirty);
            Assert.AreEqual(newPropValue, prop1.Value);
        }
Пример #3
0
        public void Test_BOPropAuthorisation_AllowRead_True()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBOPropAuthorisation   propAuthorisationStub = GetPropAuthorisationStub_CanRead_True();
            MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub();
            BOProp prop1 = (BOProp)myBoStub.Props["Prop1"];

            prop1.SetAuthorisationRules(propAuthorisationStub);

            //---------------Assert Precondition----------------
            propAuthorisationStub.IsAuthorised(prop1, BOPropActions.CanRead);

            //---------------Execute Test ----------------------
            string message;
            bool   isReadable = prop1.IsReadable(out message);

            //---------------Test Result -----------------------
            Assert.IsTrue(isReadable);
            Assert.AreEqual("", message);
        }
Пример #4
0
        public void Test_BOPropAuthorisation_AllowRead_False()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBOPropAuthorisation   propAuthorisationStub = GetPropAuthorisationStub_CanRead_False();
            MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub();
            BOProp prop1 = (BOProp)myBoStub.Props["Prop1"];

            prop1.SetAuthorisationRules(propAuthorisationStub);

            //---------------Assert Precondition----------------
            Assert.IsFalse(propAuthorisationStub.IsAuthorised(prop1, BOPropActions.CanRead));

            //---------------Execute Test ----------------------
            string message;
            bool   isReadable = prop1.IsReadable(out message);

            //---------------Test Result -----------------------
            Assert.IsFalse(isReadable);
            StringAssert.Contains("The logged on user", message);
            StringAssert.Contains(" is not authorised to read ", message);
        }