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)); } ); }
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)); }
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)); }