public void TestFromFunctionWithoutParameters() { WxeDemandMethodPermissionAttributeHelper helper = new WxeDemandMethodPermissionAttributeHelper( typeof(TestFunctionWithoutParameters), _attribute); helper.GetTypeOfSecurableObject(); }
public void TestWithDefaultParameter() { WxeDemandMethodPermissionAttributeHelper helper = new WxeDemandMethodPermissionAttributeHelper( typeof(TestFunctionWithThisObject), _attribute); Assert.That(helper.GetTypeOfSecurableObject(), Is.SameAs(typeof(SecurableObject))); }
public void TestWithParameterTypeIsBaseType() { WxeDemandTargetMethodPermissionAttribute attribute = new WxeDemandTargetMethodPermissionAttribute("ShowSpecial", typeof(DerivedSecurableObject)); WxeDemandMethodPermissionAttributeHelper helper = new WxeDemandMethodPermissionAttributeHelper( typeof(TestFunctionWithThisObject), attribute); Assert.That(helper.GetTypeOfSecurableObject(), Is.SameAs(typeof(DerivedSecurableObject))); }
public void TestWithValidParameterName() { _attribute.ParameterName = "ThisObject"; WxeDemandMethodPermissionAttributeHelper helper = new WxeDemandMethodPermissionAttributeHelper( typeof(TestFunctionWithThisObjectAsSecondParameter), _attribute); Assert.That(helper.GetTypeOfSecurableObject(), Is.SameAs(typeof(SecurableObject))); }
public void TestWithInvalidParameterName() { _attribute.ParameterName = "Invalid"; WxeDemandMethodPermissionAttributeHelper helper = new WxeDemandMethodPermissionAttributeHelper( typeof(TestFunctionWithThisObjectAsSecondParameter), _attribute); helper.GetTypeOfSecurableObject(); }
public void TestWithParameterNotImplementingISecurableObject() { _attribute.ParameterName = "SomeObject"; WxeDemandMethodPermissionAttributeHelper helper = new WxeDemandMethodPermissionAttributeHelper( typeof(TestFunctionWithThisObjectAsSecondParameter), _attribute); helper.GetTypeOfSecurableObject(); }
public void TestWithParameterNotOfNotMatchingType() { WxeDemandTargetMethodPermissionAttribute attribute = new WxeDemandTargetMethodPermissionAttribute("Show", typeof(OtherSecurableObject)); attribute.ParameterName = "ThisObject"; WxeDemandMethodPermissionAttributeHelper helper = new WxeDemandMethodPermissionAttributeHelper( typeof(TestFunctionWithThisObjectAsSecondParameter), attribute); helper.GetTypeOfSecurableObject(); }
public void TestWithHandle_InheritingHandleAttribute() { var attribute = new WxeDemandTargetMethodPermissionAttribute("Some method", typeof(SecurableObject)) { ParameterName = "HandleInheritingAttribute" }; var helper = new WxeDemandMethodPermissionAttributeHelper(typeof(TestFunctionWithHandleParameter), attribute); var result = helper.GetTypeOfSecurableObject(); Assert.That(result, Is.SameAs(typeof(SecurableObject))); }
public void TestWithHandle_PointingToSecurableObjectBase_ShouldReturnTypeDeclaredInInterface() { var attribute = new WxeDemandTargetMethodPermissionAttribute("Some method", typeof(DerivedSecurableObject)) { ParameterName = "HandleWithSecurableObject" }; var helper = new WxeDemandMethodPermissionAttributeHelper(typeof(TestFunctionWithHandleParameter), attribute); var result = helper.GetTypeOfSecurableObject(); Assert.That(result, Is.SameAs(typeof(DerivedSecurableObject))); }
public void TestWithHandle_PointingToNonSecurableObject_ShouldThrow() { var attribute = new WxeDemandTargetMethodPermissionAttribute("Some method", typeof(SecurableObject)) { ParameterName = "HandleWithNonSecurableObject" }; var helper = new WxeDemandMethodPermissionAttributeHelper(typeof(TestFunctionWithHandleParameter), attribute); Assert.That( () => helper.GetTypeOfSecurableObject(), Throws.TypeOf <WxeException>().With.Message.EqualTo( "The parameter 'HandleWithNonSecurableObject' specified by the WxeDemandTargetMethodPermissionAttribute applied to WxeFunction " + "'Remotion.Web.UnitTests.Core.Security.ExecutionEngine.TestFunctionWithHandleParameter' does not implement interface " + "'Remotion.Security.ISecurableObject'.")); }
public void TestWithHandle_ReferencedTypeNotMatchingSecurableClass_ShouldThrow() { var attribute = new WxeDemandTargetMethodPermissionAttribute("Some method", typeof(OtherSecurableObject)) { ParameterName = "HandleWithSecurableObject" }; var helper = new WxeDemandMethodPermissionAttributeHelper(typeof(TestFunctionWithHandleParameter), attribute); Assert.That( () => helper.GetTypeOfSecurableObject(), Throws.TypeOf <WxeException> ().With.Message.EqualTo( "The parameter 'HandleWithSecurableObject' specified by the WxeDemandTargetMethodPermissionAttribute applied to WxeFunction " + "'Remotion.Web.UnitTests.Core.Security.ExecutionEngine.TestFunctionWithHandleParameter' is of type " + "'Remotion.Web.UnitTests.Core.Security.Domain.SecurableObject', which is not a base type of type " + "'Remotion.Web.UnitTests.Core.Security.Domain.OtherSecurableObject'.")); }