Ejemplo n.º 1
0
        public void Test_SetValue_Fail_ReadOnly_False()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef_ReadOnlyProp1();

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

            //---------------Assert Precondition----------------
            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 property 'MyBoAuthenticationStub.Prop 1' is not editable since it is set up as ReadOnly", ex.Message);
            }
        }
Ejemplo n.º 2
0
        public void Test_SetPropertyValue_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);

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

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

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

            try
            {
                myBoStub.SetPropertyValue("Prop1", 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);
            }
        }
Ejemplo n.º 3
0
        public void Test_WriteOnce_PersistedValueSet_IsEditable_False()
        {
            //---------------Set up test pack-------------------
            PropDef propDef = new PropDef("Name", typeof(string), PropReadWriteRule.WriteOnce, "DD", "", false, false);
            BOProp  prop1   = new BOProp(propDef)
            {
                Value = "new Value", IsObjectNew = false
            };

            prop1.BackupPropValue();

            //---------------Assert Precondition----------------
            Assert.AreEqual(PropReadWriteRule.WriteOnce, prop1.PropDef.ReadWriteRule);
            Assert.IsNotNull(prop1.PersistedPropertyValue);

            //---------------Execute Test ----------------------
            string message;
            bool   isEditable = prop1.IsEditable(out message);

            //---------------Test Result -----------------------
            Assert.IsFalse(isEditable);
            StringAssert.Contains("The property ", message);
            StringAssert.Contains
                ("Name' is not editable since it is set up as WriteOnce and the value has already been set", message);
        }
Ejemplo n.º 4
0
        public void Test_ReadOnly_IsEditable_False()
        {
            //---------------Set up test pack-------------------
            PropDef propDef = new PropDef("Name", "NN", "String", PropReadWriteRule.ReadOnly, "DD", "", false, false);
            BOProp  prop1   = new BOProp(propDef);

            //---------------Assert Precondition----------------
            Assert.AreEqual(PropReadWriteRule.ReadOnly, prop1.PropDef.ReadWriteRule);

            //---------------Execute Test ----------------------
            string message;
            bool   isEditable = prop1.IsEditable(out message);

            //---------------Test Result -----------------------
            Assert.IsFalse(isEditable);
            StringAssert.Contains("The property ", message);
            StringAssert.Contains("Name' is not editable since it is set up as ReadOnly", message);
        }
Ejemplo n.º 5
0
        public void Test_WriteNew_NewObject_IsEditable_True()
        {
            //---------------Set up test pack-------------------
            PropDef propDef = new PropDef("Name", "NN", "String", PropReadWriteRule.WriteNew, "DD", "", false, false);
            BOProp  prop1   = new BOProp(propDef);

            prop1.IsObjectNew = true;

            //---------------Assert Precondition----------------
            Assert.AreEqual(PropReadWriteRule.WriteNew, prop1.PropDef.ReadWriteRule);
            Assert.IsTrue(prop1.IsObjectNew);

            //---------------Execute Test ----------------------
            string message;
            bool   isEditable = prop1.IsEditable(out message);

            //---------------Test Result -----------------------
            Assert.IsTrue(isEditable);
            Assert.AreEqual("", message);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public void Test_BOPropAuthorisation_AllowUpdate_True()
        {
            //---------------Set up test pack-------------------
            MyBoAuthenticationStub.LoadDefaultClassDef();
            IBOPropAuthorisation   propAuthorisationStub = GetPropAuthorisationStub_CanUpdate_True();
            MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub();
            BOProp prop1 = (BOProp)myBoStub.Props["Prop1"];

            prop1.SetAuthorisationRules(propAuthorisationStub);

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

            //---------------Execute Test ----------------------
            string message;
            bool   isEditable = prop1.IsEditable(out message);

            //---------------Test Result -----------------------
            Assert.IsTrue(isEditable);
            Assert.AreEqual("", message);
        }
Ejemplo n.º 8
0
        public void Test_WriteOnce_PersistedValueNotSet_IsEditable_True()
        {
            //---------------Set up test pack-------------------
            PropDef propDef = new PropDef("Name", typeof(string), PropReadWriteRule.WriteOnce, "DD", "", false, false);
            BOProp  prop1   = new BOProp(propDef);

            prop1.Value       = "new Value";
            prop1.IsObjectNew = false;

            //---------------Assert Precondition----------------
            Assert.AreEqual(PropReadWriteRule.WriteOnce, prop1.PropDef.ReadWriteRule);
            Assert.IsNull(prop1.PersistedPropertyValue);

            //---------------Execute Test ----------------------
            string message;
            bool   isEditable = prop1.IsEditable(out message);

            //---------------Test Result -----------------------
            Assert.IsTrue(isEditable);
            Assert.AreEqual("", message);
        }
Ejemplo n.º 9
0
        public void Test_WriteNotNew_NewObject_IsEditable_False()
        {
            //---------------Set up test pack-------------------
            PropDef propDef = new PropDef("Name", "NN", "String", PropReadWriteRule.WriteNotNew, "DD", "", false, false);
            BOProp  prop1   = new BOProp(propDef);

            prop1.IsObjectNew = true;

            //---------------Assert Precondition----------------
            Assert.AreEqual(PropReadWriteRule.WriteNotNew, prop1.PropDef.ReadWriteRule);
            Assert.IsTrue(prop1.IsObjectNew);

            //---------------Execute Test ----------------------
            string message;
            bool   isEditable = prop1.IsEditable(out message);

            //---------------Test Result -----------------------
            Assert.IsFalse(isEditable);
            StringAssert.Contains("The property ", message);
            StringAssert.Contains
                ("Name' is not editable since it is set up as WriteNotNew and the object is new", message);
        }