public void Method_DecoratedWithFunctionAspectThatHasNoAdvices_ThrowsAdviceNotFoundException() { var method = GetMethod("MethodWithStringParamAndBoolReturnType"); var aspect = new OnMethodBoundaryAspectAttribute(typeof(NoAdviceAspect)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public void MethodWithoutReturn_DecoratedWithOnActionBoundaryAspectWithNewMethodOfOnExitThatHasMoreThenOneArgument_ThrowsAspectTypeMismatchException() { var method = GetMethod("MethodWithoutParams"); var aspect = new OnMethodBoundaryAspectAttribute(typeof(TestMethodBounadryAspectAspectWithNewMethodOfOnExitThatHasMoreThenOneArgument)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public void ParameterslessMethodAndNoReturnType_DecoratedWithFunctionAspect_ThrowsAspectAnnotationException() { var method = GetMethod("MethodWithoutParams"); var aspect = new OnMethodBoundaryAspectAttribute(typeof(TestAspect)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public void ParameterslessMethodWithReturnType_DecoratedWithFunctionAspectThatHasAtLeastOneParameter_ThrowsAspectTypeMismatchException() { var method = GetMethod("MethodWithoutParamsWithBoolReturnType"); var aspect = new OnMethodBoundaryAspectAttribute(typeof(TestAspect)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public void MethodWithAReturnType_DecoratedWithActionAspect_ThrowsAspectTypeMismatchException() { var method = GetMethod("MethodWithStringParamAndBoolReturnType"); var aspect = new OnMethodBoundaryAspectAttribute(typeof(TestAspect6)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public void MethodWithOneParemeterAndReturnType_DecoratedWithFunctionAspectThatHasDifferentSetOfParameters_ThrowsAspectTypeMismatchException() { var method = GetMethod("MethodWithStringParamAndBoolReturnType"); var aspect = new OnMethodBoundaryAspectAttribute(typeof(TestAspect4)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public void OnMethodBoundaryAspectAttribute_GivenAnInterceptionAspectTypeAsAnArgument_ThrowsAspectAnnotationException() { var method = GetMethod("MethodWithStringParamAndBoolReturnType"); var aspect = new OnMethodBoundaryAspectAttribute(typeof(TestInterceptionAspect)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public void MethodWithoutReturnType_DecoratedWithOnFunctionBoundaryAspectAttribute_ThrowsAspectAnnotationException() { var method = GetMethod("MethodWithStringParamAndVoidReturnType"); var aspect = new OnMethodBoundaryAspectAttribute(typeof(TestAspect)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public void ParameterlessWithReturnTypeMethod_DecoratedWithMatchedFunctionAspectsWithoutParametersAndReturnType_ReturnsNoErrorFromValidation() { var method = GetMethod("MethodWithoutParamsWithBoolReturnType"); var aspect = new OnMethodBoundaryAspectAttribute(typeof(TestAspect2)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public void MethodWithStringParamAndBoolReturnType_DecoratedWithMatchedOnFunctionBoundaryAspect_ReturnsNoErrorFromValidation() { var method = GetMethod("MethodWithStringParamAndBoolReturnType"); var aspect = new OnMethodBoundaryAspectAttribute(typeof(TestAspect)); AspectTypeValidator.ValidateMethodAspect(aspect, method); }
public Func <IAspectDefinition, IAspectExpressionBuilder> Visit(OnMethodBoundaryAspectAttribute aspect) { return(aspectDefinition => { Func <IAspectExpression, IAspectExpression> ctor = null; var _topAspectInScopeDefinition = topAspectInScopeDefinition; var methodAspectDefinition = aspectDefinition as IMethodAspectDefinition; if (lastAspect.Top) { ctor = expression => { return new TopOnMethodBoundaryAspectExpression(expression, methodAspectDefinition); }; lastAspect = new Aspect(); } else { if (lastAspect.IsInBinding) { if (lastAspect.IsTopBinding) { lastAspect.IsTopBinding = false; ctor = expression => { return new TopBindingOnMethodBoundaryAspectExpression(expression, methodAspectDefinition); }; } else { ctor = expression => { return new BindingOnMethodBoundaryAspectExpression(expression, methodAspectDefinition, _topAspectInScopeDefinition); }; } } else { ctor = expression => { return new NestedOnMethodBoundaryAspectExpression(expression, methodAspectDefinition); }; } } topAspectInScopeDefinition = aspectDefinition; return new AspectNodeExpressionBuilder(ctor); }); }
public Func <IAspectDefinition, IAspectExpressionBuilder> Visit(OnMethodBoundaryAspectAttribute aspect) { return((IAspectDefinition aspectDefinition) => { Func <IAspectExpression, IAspectExpression> ctor = null; if (lastAspect.Top) { ctor = Functional.Curry <IAspectExpression, IAspectExpression>(expression => { return new TopOnMethodBoundaryAspectExpression(expression, aspectDefinition); }); lastAspect = new Aspect(); } else { if (lastAspect.IsInBinding) { ctor = Functional.Curry <IAspectExpression, IAspectExpression>(expression => { return new BindingOnMethodBoundaryAspectExpression(expression, aspectDefinition); }); } else { var _previousAspectDefinition = previousAspectDefinition; ctor = Functional.Curry <IAspectExpression, IAspectExpression>(expression => { return new NestedOnMethodBoundaryAspectExpression(expression, aspectDefinition, _previousAspectDefinition); }); } } previousAspectDefinition = aspectDefinition; return new AspectNodeExpressionBuilder(ctor); }); }
internal OnMethodBoundaryAspectDefinition(OnMethodBoundaryAspectAttribute aspect, Type aspectDeclaringType, MemberInfo member) : base(aspect, aspectDeclaringType, member) { this.aspect = aspect; }