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_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_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_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_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_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); }
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); }
internal protected void SetAuthorisation(IBusinessObjectAuthorisation authorisationStub) { SetAuthorisationRules(authorisationStub); }
// protected internal Customer(ClassDef def) // : base(def) // { // IBOPropAuthorisation propAuthorisationStub = new CustomerNameAuthorisationPolicy(); // BOProp propCustomerName = (BOProp)this.Props["CustomerName"]; // propCustomerName.SetAuthorisationRules(propAuthorisationStub); // // PropDef propDef = (PropDef) propCustomerName.PropDef; // propDef.AddPropRule(new MyPropRule(this, propCustomerName)); // } /// <summary> /// This method has been added and made public purely for the purposes of testing. /// </summary> /// <param name="authorisation"></param> public void SetAuthorisation(IBusinessObjectAuthorisation authorisation) { SetAuthorisationRules(authorisation); }