public void ShouldCreateHandlerWithReasonableDefaults() { string ruleName = "Some Rule"; AuthorizationCallHandlerAttribute attribute = new AuthorizationCallHandlerAttribute(ruleName); AuthorizationCallHandler handler = GetHandlerFromAttribute(attribute); Assert.AreEqual(string.Empty, handler.ProviderName); Assert.AreEqual(ruleName, handler.OperationName); }
public void ShouldBeAbleToSetProviderName() { string ruleName = "Some other rule - {namespace}"; string providerName = "MyRules"; AuthorizationCallHandlerAttribute attribute = new AuthorizationCallHandlerAttribute(ruleName); attribute.ProviderName = providerName; AuthorizationCallHandler handler = GetHandlerFromAttribute(attribute); Assert.AreEqual(ruleName, handler.OperationName); Assert.AreEqual(providerName, handler.ProviderName); }
public void ShouldBeAbleToSetProviderName() { container.RegisterInstance("MyRules", authorizationProvider); string ruleName = "Some other rule - {namespace}"; string providerName = "MyRules"; AuthorizationCallHandlerAttribute attribute = new AuthorizationCallHandlerAttribute(ruleName); attribute.ProviderName = providerName; AuthorizationCallHandler handler = GetHandlerFromAttribute(attribute); Assert.AreSame(authorizationProvider, handler.AuthorizationProvider); Assert.AreEqual(ruleName, handler.OperationName); }
public void ShouldCreateHandlerWithReasonableDefaults() { container.RegisterInstance(authorizationProvider); string ruleName = "Some Rule"; AuthorizationCallHandlerAttribute attribute = new AuthorizationCallHandlerAttribute(ruleName); attribute.Order = 500; AuthorizationCallHandler handler = GetHandlerFromAttribute(attribute); Assert.AreSame(authorizationProvider, handler.AuthorizationProvider); Assert.AreEqual(ruleName, handler.OperationName); Assert.AreEqual(500, handler.Order); }
public void CreatesHandlerProperlyFromAttributes() { MethodInfo method = typeof(AuthorizationTestTarget).GetMethod("GetName"); Assert.IsNotNull(method); object[] attributes = method.GetCustomAttributes(typeof(AuthorizationCallHandlerAttribute), false); Assert.AreEqual(1, attributes.Length); AuthorizationCallHandlerAttribute att = attributes[0] as AuthorizationCallHandlerAttribute; ICallHandler callHandler = att.CreateHandler(AllowFredPolicyContainer); Assert.IsNotNull(callHandler); Assert.AreEqual(3, callHandler.Order); }