Exemplo n.º 1
0
        public async Task GetRemainingCountAsync()
        {
            // Arrange
            var apiResponse = @"{
				'results': [
					{
						'remaining': 2,
						'period': 'month',
						'price_per_ip': 20
					}
				]
			}"            ;

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(HttpMethod.Get, Utils.GetSendGridApiUri(ENDPOINT, "remaining")).Respond("application/json", apiResponse);

            var client      = Utils.GetFluentClient(mockHttp);
            var ipAddresses = new IpAddresses(client);

            // Act
            var result = await ipAddresses.GetRemainingCountAsync(CancellationToken.None).ConfigureAwait(false);

            // Assert
            mockHttp.VerifyNoOutstandingExpectation();
            mockHttp.VerifyNoOutstandingRequest();
            result.ShouldNotBeNull();
            result.Period.ShouldBe("month");
            result.PricePerIp.ShouldBe(20.0);
            result.Remaining.ShouldBe(2);
        }