public async Task HandleAsync(IExternalTaskContext context)
        {
            IExecutionResult executionResult;

            try
            {
                executionResult = await Process(context.Task);
            }
            catch (Exception e)
            {
                executionResult = new FailureResult(e);
            }

            await executionResult.ExecuteResultAsync(context);
        }
Esempio n. 2
0
        public async Task TestExecuteResultAsync()
        {
            Expression <Func <IExternalTaskContext, Task> > expression = context => context.ReportFailureAsync(
                It.IsAny <string>(),
                It.IsAny <string>(),
                It.IsAny <int?>(),
                It.IsAny <int?>()
                );

            _contextMock
            .Setup(expression)
            .Returns(Task.CompletedTask);

            var result = new FailureResult(new Exception("Message"));

            await result.ExecuteResultAsync(_contextMock.Object);

            _contextMock.Verify(expression, Times.Once());
            _contextMock.VerifyNoOtherCalls();
        }