public void TestThatBaseNativeTypesCandBeBindedAndInvoked() { MethodBinder binder = new MethodBinder(_methodInfo, new HeyRememberDto() { DomainSpecificData = "[1, \"banana\"]" }); MethodExecutionResultEnum result = binder.Invoke(); Assert.AreEqual(1, BindingTester.L); Assert.AreEqual("banana", BindingTester.S); Assert.AreEqual(MethodExecutionResultEnum.Ok, result); }
public void TestThatWhenTheMethodCantBeBoundTheExceptionHandlerIsCalled() { Mock <IHeyExceptionHandler> exceptionHandlerMock = new Mock <IHeyExceptionHandler>(); MethodBinder binder = new MethodBinder(_methodInfo, new HeyRememberDto() { DomainSpecificData = "[1, 2]" }, exceptionHandlerMock.Object); MethodExecutionResultEnum result = binder.Invoke(); exceptionHandlerMock.Verify(handler => handler.Handle(It.IsAny <Exception>())); Assert.AreEqual(MethodExecutionResultEnum.Fail, result); }
public MethodExecutionResultEnum Execute(HeyRememberDto heyRemember) { var now = DateTime.UtcNow; if (now < heyRemember.When[0].ToUniversalTime()) { _log.Info($"{heyRemember}, will be executed on {heyRemember.When[0]}"); return(MethodExecutionResultEnum.Empty); } ResolveMethodByFireMeAttribute resolveMethod = new ResolveMethodByFireMeAttribute(_exceptionHandler); IMethodBinder binder = resolveMethod.Find(heyRemember); MethodExecutionResultEnum result = binder.Invoke(); _log.Info($"execution of {heyRemember}: {result}"); if (result != MethodExecutionResultEnum.Ok) { throw new DeferredExecutionException($"The execution of {heyRemember} failed: see logs for details"); } return(result); }
public BinderCanCallTheMethod(IMethodBinder methodBinder) { Can = false; ExecutionResultEnum = methodBinder.Invoke(this); Can = Can && ExecutionResultEnum == MethodExecutionResultEnum.Ok; }