public void Test_LoadExistingBO_Fail_AllowRead_False()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanCreate_True();
            MyBoAuthenticationStub       myBoStub          = new MyBoAuthenticationStub();

            myBoStub.SetAuthorisation(authorisationStub);
            myBoStub.Save();

            authorisationStub = GetAuthorisationStub_CanRead_False();
            myBoStub.SetAuthorisation(authorisationStub);
            IPrimaryKey id = myBoStub.ID;

            FixtureEnvironment.ClearBusinessObjectManager();

            //---------------Assert Precondition----------------
            Assert.IsFalse(authorisationStub.IsAuthorised(myBoStub, BusinessObjectActions.CanRead));
            Assert.IsFalse(myBoStub.Status.IsNew);

            //---------------Execute Test ----------------------
            myBoStub = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <MyBoAuthenticationStub>(id);
            try
            {
                myBoStub.GetPropertyValue("Prop1");
                Assert.Fail("expected Err");
            }
            //---------------Test Result -----------------------
            catch (BusObjReadException ex)
            {
                StringAssert.Contains("The logged on user", ex.Message);
                StringAssert.Contains("is not authorised to read ", ex.Message);
            }
        }
        public void Test_SetValue_Fail_AllowUpdate_False()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanUpdate_False();

            MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub();

            myBoStub.SetAuthorisation(authorisationStub);
            myBoStub.Save();

            //---------------Assert Precondition----------------
            Assert.IsFalse(authorisationStub.IsAuthorised(myBoStub, BusinessObjectActions.CanUpdate));
            Assert.IsFalse(myBoStub.Status.IsNew);
            Assert.IsFalse(myBoStub.Status.IsDirty);

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

            try
            {
                myBoStub.SetPropertyValue("Prop1", newPropValue);
                Assert.Fail("expected Err");
            }
            //---------------Test Result -----------------------
            catch (BusObjEditableException ex)
            {
                StringAssert.Contains("You cannot Edit ", ex.Message);
                StringAssert.Contains("as the IsEditable is set to false for the object", ex.Message);
            }
        }
        public void Test_LoadExistingBO_AllowRead_True()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanCreate_True();
            MyBoAuthenticationStub       myBoStub          = new MyBoAuthenticationStub();

            myBoStub.SetAuthorisation(authorisationStub);
            myBoStub.Save();

            authorisationStub = GetAuthorisationStub_CanRead_True();
            myBoStub.SetAuthorisation(authorisationStub);
            IPrimaryKey id = myBoStub.ID;

            FixtureEnvironment.ClearBusinessObjectManager();

            //---------------Assert Precondition----------------
            Assert.IsTrue(authorisationStub.IsAuthorised(myBoStub, BusinessObjectActions.CanRead));
            Assert.IsFalse(myBoStub.Status.IsNew);

            //---------------Execute Test ----------------------
            myBoStub = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <MyBoAuthenticationStub>(id);
            object value = myBoStub.GetPropertyValue("Prop1");

            //---------------Test Result -----------------------
            Assert.IsNull(value);
            Assert.IsFalse(myBoStub.Status.IsDirty);
        }
        public void Test_SaveNewBO_Fail_AllowCreate_False()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanCreate_False();

            MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub();

            myBoStub.SetAuthorisation(authorisationStub);

            //---------------Assert Precondition----------------
            Assert.IsFalse(authorisationStub.IsAuthorised(myBoStub, BusinessObjectActions.CanCreate));

            //---------------Execute Test ----------------------
            try
            {
                myBoStub.Save();
                Assert.Fail("expected Err");
            }
            //---------------Test Result -----------------------
            catch (BusObjPersistException ex)
            {
                StringAssert.Contains("The logged on user", ex.Message);
                StringAssert.Contains("is not authorised to create ", ex.Message);
            }
        }
        public void Test_SetValue_AllowUpdate_True()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanUpdate_True();

            MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub();

            myBoStub.SetAuthorisation(authorisationStub);
            myBoStub.Save();

            //---------------Assert Precondition----------------
            Assert.IsTrue(authorisationStub.IsAuthorised(myBoStub, BusinessObjectActions.CanUpdate));
            Assert.IsFalse(myBoStub.Status.IsNew);
            Assert.IsFalse(myBoStub.Status.IsDirty);

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

            myBoStub.SetPropertyValue("Prop1", newPropValue);

            //---------------Test Result -----------------------
            Assert.IsTrue(myBoStub.Status.IsDirty);
            Assert.AreEqual(newPropValue, myBoStub.GetPropertyValue("Prop1"));
        }
Beispiel #6
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);
            }
        }
Beispiel #7
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);
        }
Beispiel #8
0
        public void Test_SetValue_Fail_AllowUpdate_False()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBOPropAuthorisation propAuthorisationStub = GetPropAuthorisationStub_CanUpdate_False();

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

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

            //---------------Assert Precondition----------------
            Assert.IsFalse(propAuthorisationStub.IsAuthorised(prop1, BOPropActions.CanUpdate));
            Assert.IsFalse(myBoStub.Status.IsNew);
            string message;

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

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

            try
            {
                prop1.Value = newPropValue;
                Assert.Fail("expected Err");
            }
            //---------------Test Result -----------------------
            catch (BOPropWriteException ex)
            {
                StringAssert.Contains("The logged on user  is not authorised to update the Prop1 ", ex.Message);
            }
        }
        public void Test_SaveNewBO_AllowCreate_True()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanCreate_True();

            MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub();

            myBoStub.SetAuthorisation(authorisationStub);

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

            //---------------Execute Test ----------------------
            myBoStub.Save();
            //---------------Test Result -----------------------
        }
        public void Test_BusinessObjectAuthorisation_AllowDelete_False()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanDelete_False();
            MyBoAuthenticationStub       myBoStub          = new MyBoAuthenticationStub();

            myBoStub.SetAuthorisation(authorisationStub);
            //---------------Assert Precondition----------------
            Assert.IsFalse(authorisationStub.IsAuthorised(myBoStub, BusinessObjectActions.CanDelete));
            //---------------Execute Test ----------------------
            string message;
            bool   isDeletable = myBoStub.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-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanDelete_True();
            MyBoAuthenticationStub       myBoStub          = new MyBoAuthenticationStub();

            myBoStub.SetAuthorisation(authorisationStub);

            //---------------Assert Precondition----------------
            Assert.IsTrue(authorisationStub.IsAuthorised(myBoStub, BusinessObjectActions.CanDelete));

            //---------------Execute Test ----------------------
            string message;
            bool   isDeletable = myBoStub.IsDeletable(out message);

            //---------------Test Result -----------------------
            Assert.IsTrue(isDeletable);
            Assert.AreEqual("", message);
        }
Beispiel #12
0
        public void Test_IsReadable_ViaIBOProp_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 = myBoStub.Props["Prop1"].IsReadable(out message);

            //---------------Test Result -----------------------
            Assert.IsTrue(isReadable);
            Assert.AreEqual("", message);
        }
Beispiel #13
0
        public void Test_BOPropAuthorisation_AllowUpdate_False()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBOPropAuthorisation   propAuthorisationStub = GetPropAuthorisationStub_CanUpdate_False();
            MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub();
            BOProp prop1 = (BOProp)myBoStub.Props["Prop1"];

            prop1.SetAuthorisationRules(propAuthorisationStub);

            //---------------Assert Precondition----------------
            Assert.IsFalse(propAuthorisationStub.IsAuthorised(prop1, BOPropActions.CanUpdate));
            //---------------Execute Test ----------------------
            string message;
            bool   isEditable = prop1.IsEditable(out message);

            //---------------Test Result -----------------------
            Assert.IsFalse(isEditable);
            StringAssert.Contains("The logged on user", message);
            StringAssert.Contains(" is not authorised to update ", message);
        }
        public void Test_DeleteBO_AllowDelete_True()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanDelete_True();

            MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub();

            myBoStub.SetAuthorisation(authorisationStub);
            myBoStub.Save();

            //---------------Assert Precondition----------------
            Assert.IsTrue(authorisationStub.IsAuthorised(myBoStub, BusinessObjectActions.CanDelete));
            Assert.IsFalse(myBoStub.Status.IsNew);

            //---------------Execute Test ----------------------
            myBoStub.MarkForDelete();
            myBoStub.Save();

            //---------------Test Result -----------------------
            Assert.IsTrue(myBoStub.Status.IsDeleted);
            Assert.IsTrue(myBoStub.Status.IsNew);
        }