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_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")); }
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); } }
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); } }
public void Test_SaveExistingBO_AllowUpdate_True() { //---------------Set up test pack------------------- MyBoAuthenticationStub.LoadDefaultClassDef(); IBusinessObjectAuthorisation authorisationStub = GetAuthorisationStub_CanUpdate_True(); MyBoAuthenticationStub myBoStub = new MyBoAuthenticationStub(); myBoStub.SetAuthorisation(authorisationStub); myBoStub.Save(); myBoStub.SetPropertyValue("Prop1", "1112"); //---------------Assert Precondition---------------- Assert.IsTrue(authorisationStub.IsAuthorised(myBoStub, BusinessObjectActions.CanUpdate)); Assert.IsFalse(myBoStub.Status.IsNew); Assert.IsTrue(myBoStub.Status.IsDirty); //---------------Execute Test ---------------------- myBoStub.Save(); //---------------Test Result ----------------------- Assert.IsFalse(myBoStub.Status.IsDirty); }