public void TestThatTheResolverReturnCorrectlyWhenCantFindTheMethod()
        {
            ResolveMethodByFireMeAttribute resolver = new ResolveMethodByFireMeAttribute();
            IMethodBinder method = resolver.Find(new HeyRememberDto()
            {
                Domain = "Hey.Api.Rest.Tests",
                Type   = "",
                Name   = "ThisMethodDoesntExists"
            });

            Assert.AreEqual(MethodExecutionResultEnum.Empty, method.Invoke());
        }
        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);
        }
Beispiel #3
0
 public BinderCanCallTheMethod(IMethodBinder methodBinder)
 {
     Can = false;
     ExecutionResultEnum = methodBinder.Invoke(this);
     Can = Can && ExecutionResultEnum == MethodExecutionResultEnum.Ok;
 }