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_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_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_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_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_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); }