public void CountMessages_ShouldReturnZero_WhenResponseContainsEmptyBytes()
        {
            var reader = new ReceiveMessageResponseReader();

            var count = reader.CountMessages(Array.Empty <byte>());

            count.Should().Be(0);
        }
        public void CountMessages_ShouldReturnZero_WhenResponseContainsNoMessages()
        {
            var bytes = Encoding.UTF8.GetBytes(EmptyResponse);

            var reader = new ReceiveMessageResponseReader();

            var count = reader.CountMessages(bytes);

            count.Should().Be(0);
        }
        public void CountMessages_ShouldNotReturnGreaterThanTen_EvenIfDataContainsMoreMessages()
        {
            var sb = new StringBuilder();

            sb.Append(ResponseStart);
            for (var i = 0; i < 15; i++) // response with 15 messages
            {
                sb.Append(Message);
            }
            sb.Append(ResponseEnd);

            var bytes = Encoding.UTF8.GetBytes(sb.ToString());

            var reader = new ReceiveMessageResponseReader();

            var count = reader.CountMessages(bytes);

            count.Should().Be(10, because: "An AWS SQS receive request returns a maximum of 10 messages");
        }
        public void CountMessages_ShouldReturnCorrectCount_WhenResponseContainsMessages(int messages)
        {
            var sb = new StringBuilder();

            sb.Append(ResponseStart);
            for (var i = 0; i < messages; i++)
            {
                sb.Append(Message);
            }
            sb.Append(ResponseEnd);

            var bytes = Encoding.UTF8.GetBytes(sb.ToString());

            var reader = new ReceiveMessageResponseReader();

            var count = reader.CountMessages(bytes);

            count.Should().Be(messages);
        }
Exemple #5
0
        public int CountMessages()
        {
            var reader = new ReceiveMessageResponseReader();

            return(reader.CountMessages(_responseBytes));
        }