Exemplo n.º 1
0
        public async Task ProcessAsync_InvalidPrincipalNameFormat_RetunsBadRequestHttpResponse()
        {
            // Arrange
            PrincipalIdentityName = string.Empty;

            // Act
            var actual = await Target.ProcessAsync(GetMessagesHttpRequest, GetMessagesUriTemplateMatch, It.IsAny <ITransportSession>(), CancellationToken);

            // Assert
            actual.CorrelatorId.ShouldBe(GetMessagesHttpRequest.CorrelatorId);
            actual.StatusCode.ShouldBe(HttpStatusCode.BadRequest);
            EnvelopeStorage.Verify();
        }
Exemplo n.º 2
0
        public async Task ProcessAsync_RequestUriWithoutId_RetunsBadRequestHttpResponse()
        {
            // Arrange
            GetMessageUriTemplateMatch.BoundVariables.Clear();

            // Act
            var actual = await Target.ProcessAsync(GetMessageHttpRequest, GetMessageUriTemplateMatch, It.IsAny <ITransportSession>(), CancellationToken.None);

            // Assert
            actual.CorrelatorId.ShouldBe(GetMessageHttpRequest.CorrelatorId);
            actual.StatusCode.ShouldBe(HttpStatusCode.BadRequest);
            EnvelopeStorage.Verify();
        }
Exemplo n.º 3
0
        public async Task ProcessAsync_NonExistingId_ReturnsNotFoundHttpResponse()
        {
            // Arrange
            EnvelopeStorage
            .Setup(m => m.GetEnvelopeAsync(Identity, EnvelopeId))
            .ReturnsAsync(null)
            .Verifiable();

            // Act
            var actual = await Target.ProcessAsync(GetMessageHttpRequest, GetMessageUriTemplateMatch, It.IsAny <ITransportSession>(), CancellationToken);

            // Assert
            EnvelopeStorage.Verify();
            actual.CorrelatorId.ShouldBe(GetMessageHttpRequest.CorrelatorId);
            actual.StatusCode.ShouldBe(HttpStatusCode.NotFound);
        }
Exemplo n.º 4
0
        public async Task ProcessAsync_NoStoredEnvelopesForIdentity_ReturnsNoContentHttpResponse()
        {
            // Arrange
            EnvelopeStorage
            .Setup(m => m.GetEnvelopesAsync(Identity))
            .ReturnsAsync(new string[0])
            .Verifiable();

            // Act
            var actual = await Target.ProcessAsync(GetMessagesHttpRequest, GetMessagesUriTemplateMatch, It.IsAny <ITransportSession>(), CancellationToken);

            // Assert
            actual.StatusCode.ShouldBe(HttpStatusCode.NoContent);
            actual.BodyStream.ShouldBe(null);
            actual.ContentType.ShouldBe(null);
            EnvelopeStorage.Verify();
        }
Exemplo n.º 5
0
        public async Task ProcessAsync_ExistingId_GetsFromStorageAndReturnsOKHttpResponse()
        {
            // Arrange
            EnvelopeStorage
            .Setup(m => m.GetEnvelopeAsync(Identity, EnvelopeId))
            .ReturnsAsync(Envelope)
            .Verifiable();

            // Act
            var actual = await Target.ProcessAsync(GetMessageHttpRequest, GetMessageUriTemplateMatch, It.IsAny <ITransportSession>(), CancellationToken);

            // Assert
            EnvelopeStorage.Verify();
            Target.Envelope.ShouldNotBe(null);
            Target.Envelope.ShouldBe(Envelope);
            Target.Request.ShouldNotBe(null);
            Target.Request.ShouldBe(GetMessageHttpRequest);
            actual.ShouldBe(GetMessageHttpResponse);
            actual.Headers[Constants.ENVELOPE_FROM_HEADER].ShouldBe(Envelope.From.ToString());
            actual.Headers[Constants.ENVELOPE_TO_HEADER].ShouldBe(Envelope.To.ToString());
            actual.Headers[Constants.ENVELOPE_PP_HEADER].ShouldBe(Envelope.Pp.ToString());
        }
Exemplo n.º 6
0
        public async Task ProcessAsync_ValidHttpRequest_CallsStorageAndReturnsOKHttpResponse()
        {
            // Arrange
            EnvelopeStorage
            .Setup(m => m.GetEnvelopesAsync(Identity))
            .ReturnsAsync(EnvelopeIds)
            .Verifiable();

            // Act
            var actual = await Target.ProcessAsync(GetMessagesHttpRequest, GetMessagesUriTemplateMatch, It.IsAny <ITransportSession>(), CancellationToken);

            // Assert
            actual.StatusCode.ShouldBe(HttpStatusCode.OK);
            actual.BodyStream.ShouldNotBe(null);
            var reader = new StreamReader(actual.BodyStream);

            foreach (var messageId in EnvelopeIds)
            {
                reader.ReadLine().ShouldBe(messageId.ToString());
            }
            actual.ContentType.ShouldNotBe(null);
            actual.ContentType.ToString().ShouldBe(Constants.TEXT_PLAIN_HEADER_VALUE);
            EnvelopeStorage.Verify();
        }