public async Task ProcessRequestAsync_ValidExecutionRequest_ShouldPutExecutionResultUpdateToExecutionApi() { var mockExecAdapter = new Mock <IExecutionAdapter>(); var mockJsonHttpClient = new Mock <IJsonHttpClient>(); var mockLogger = new Mock <ILogger <AsyncExecutionProcessor <IExecutionAdapter> > >(); var asyncExecProcessor = new AsyncExecutionProcessor <IExecutionAdapter>( mockExecAdapter.Object, mockJsonHttpClient.Object, mockLogger.Object, defaultProcessorOptions); var execRequest = CreateDefaultExecutionRequest(); var execContext = execRequest.ToExecutionContext().UpdateStatus(ExecutionStatus.Succeeded); mockExecAdapter.Setup(ea => ea.ExecuteAsync(execRequest, It.IsAny <CancellationToken>())) .Returns(Task.FromResult(execContext)); ExecutionUpdate execUpdate1 = null; ExecutionUpdate execUpdate2 = null; mockJsonHttpClient.Setup(hc => hc.PutAsync(execRequest.UpdateExecutionStatusUrl, It.IsAny <ExecutionUpdate>())) .Returns(Task.FromResult(new HttpResponse(HttpStatusCode.OK))) .Callback <string, object>((u, eu) => { if (execUpdate1 == null) { execUpdate1 = eu as ExecutionUpdate; } else { execUpdate2 = eu as ExecutionUpdate; } }); await asyncExecProcessor.ProcessRequestAsync(execRequest, CancellationToken.None); execUpdate2.Should().NotBeNull(); execUpdate2.Status.Should().Be(ExecutionStatus.Succeeded.ToString()); }
private async Task UpdateExecutionStatusAsync(string updateUrl, ExecutionUpdate execUpdate) => await jsonHttpClient.PutAsync(updateUrl, execUpdate);