public async Task ProcessAsync_FailuresCommand_CallsTransportAndReturnsErrorHttpResponse() { // Arrange TransportSession .Setup(t => t.ProcessCommandAsync(It.Is <Command>(c => c.Id == RequestCommand.Id && c.Uri.Equals(RequestCommand.Uri)), CancellationToken)) .ReturnsAsync(FailedResponseCommand) .Verifiable(); // Act var actual = await Target.ProcessAsync(SendCommandHttpRequest, It.IsAny <UriTemplateMatch>(), TransportSession.Object, CancellationToken); // Assert TransportSession.Verify(); actual.StatusCode.ShouldBe(FailedResponseCommand.Reason.ToHttpStatusCode()); actual.StatusDescription.ShouldBe(FailedResponseCommand.Reason.Description); }
public async Task ProcessAsync_SyncRequestDispatchedNotification_CallsTransportAndReturnsCreatedHttpResponse() { // Arrange TransportSession .Setup(t => t.ProcessMessageAsync(It.Is <Message>(m => m.Id == Message.Id && m.Content.ToString().Equals(Content)), WaitUntilEvent, CancellationToken)) .ReturnsAsync(DispatchedNotification) .Verifiable(); // Act var actual = await Target.ProcessAsync(SendMessageHttpRequest, It.IsAny <UriTemplateMatch>(), TransportSession.Object, CancellationToken); // Assert actual.CorrelatorId.ShouldBe(SendMessageHttpRequest.CorrelatorId); actual.StatusCode.ShouldBe(HttpStatusCode.Created); TransportSession.Verify(); }
public async Task ProcessAsync_SuccessCommand_CallsTransportAndReturnsOKHttpResponse() { // Arrange TransportSession .Setup(t => t.ProcessCommandAsync(It.Is <Command>(c => c.Id == RequestCommand.Id && c.Uri.Equals(RequestCommand.Uri)), CancellationToken)) .ReturnsAsync(SuccessResponseCommand) .Verifiable(); // Act var actual = await Target.ProcessAsync(SendCommandHttpRequest, It.IsAny <UriTemplateMatch>(), TransportSession.Object, CancellationToken); // Assert TransportSession.Verify(); actual.StatusCode.ShouldBe(HttpStatusCode.OK); DocumentSerializer.Verify(s => s.Serialize(It.IsAny <Document>()), Times.Never()); }