public async Task ProcessAsync_ValidEnvelope_CallsTransport() { // Act var actual = await Target.ProcessAsync(SendMessageHttpRequest, It.IsAny <UriTemplateMatch>(), TransportSession.Object, CancellationToken); // Assert actual.CorrelatorId.ShouldBe(SendMessageHttpRequest.CorrelatorId); actual.StatusCode.ShouldBe(System.Net.HttpStatusCode.Accepted); TransportSession.Verify(t => t.SubmitAsync(It.Is <Message>(m => m.Id == Envelope.Id && m.From.Equals(Envelope.From) && m.To.Equals(Envelope.To)), CancellationToken), Times.Once()); Target.Request.ShouldBe(SendMessageHttpRequest); }
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_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_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()); }