예제 #1
0
        public void GivenAnIncorrectMessageUsageHeader_WhenGetMessageUsage_ThenItShouldNotThrow()
        {
            var responseContent = new HttpResponseMessage(HttpStatusCode.OK);

            Assert.DoesNotThrow(() =>
            {
                var errorCode = ExecutorREST.GetMessagesUsage(responseContent, "wrong-header-name");
                Assert.That(errorCode, Is.EqualTo(-1));
            }
                                );
        }
예제 #2
0
        public void GivenACorrectMessageUsageHeader_WhenGetMessageUsage_ThenItShouldReturnCorrectValue()
        {
            //Arrange
            var responseContent = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Headers =
                {
                    { "iexcloud-messages-used", "1234" }
                }
            };

            //Arrange
            var result = ExecutorREST.GetMessagesUsage(responseContent, "iexcloud-messages-used");

            //Assert
            Assert.That(result, Is.EqualTo(1234));
        }
예제 #3
0
        public void GivenAMessageUsageHeaderWithNonParseableValue_WhenGetMessageUsage_ThenItShouldReturnSomeErrorCode()
        {
            //Arrange
            var responseContent = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Headers =
                {
                    { "not-int-parseable", "abc" }
                }
            };

            //Arrange
            var result = ExecutorREST.GetMessagesUsage(responseContent, "not-int-parseable");

            //Assert
            Assert.That(result, Is.EqualTo(-2));
        }