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); } }
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); }
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_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); }
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); }
/// <summary> /// Set the authorisation rule strategy to be used /// </summary> /// <param name="boPropAuthorisation"></param> public void SetAuthorisationRules(IBOPropAuthorisation boPropAuthorisation) { _boPropAuthorisation = boPropAuthorisation; }
/// <summary> /// Set the authorisation rule strategy to be used /// </summary> /// <param name="boPropAuthorisation"></param> public void SetAuthorisationRules(IBOPropAuthorisation boPropAuthorisation) { _boPropAuthorisation = boPropAuthorisation; }