public async Task WhenCryptocurrencyIsNotSupportedReturnsNotFound() { const string cryptocurrency = "unknownCryptocurrency"; var endpointUnderTest = $"/api/priceindex/{cryptocurrency}"; _mockProviderService .UponReceiving($"A GET request to get price indexes for '{cryptocurrency}' cryptocurrency") .With(new ProviderServiceRequest { Method = HttpVerb.Get, Path = endpointUnderTest }) .WillRespondWith(new ProviderServiceResponse { Status = (int)HttpStatusCode.NotFound }); var consumer = new TestWebClient(_mockProviderServiceBaseUri); var(statusCode, coinDeskResponse) = await consumer.Get(endpointUnderTest); Assert.Equal(HttpStatusCode.NotFound, statusCode); Assert.Null(coinDeskResponse); _mockProviderService.VerifyInteractions(); }
public async Task WhenCryptocurrencyIsSupportedReturnsPriceIndexes() { const string cryptocurrency = "bitcoin"; var endpointUnderTest = $"/api/priceindex/{cryptocurrency}"; _mockProviderService .UponReceiving($"A GET request to get price indexes for '{cryptocurrency}' cryptocurrency") .With(new ProviderServiceRequest { Method = HttpVerb.Get, Path = endpointUnderTest }) .WillRespondWith(new ProviderServiceResponse { Headers = new Dictionary <string, object> { { "Content-Type", "application/json; charset=utf-8" } }, Status = (int)HttpStatusCode.OK, Body = new { lastUpdatedIso = "Nov 11, 2019 at 22:12 GMT", priceIndexes = new [] { new { code = "EUR", symbol = "€", rate = 7920.6637, }, new { code = "GBP", symbol = "£", rate = 6799.1343, }, new { code = "USD", symbol = "$", rate = 8739.3483, } } } }); var consumer = new TestWebClient(_mockProviderServiceBaseUri); var(statusCode, coinDeskResponse) = await consumer.Get(endpointUnderTest); Assert.Equal(HttpStatusCode.OK, statusCode); Assert.NotNull(coinDeskResponse); _mockProviderService.VerifyInteractions(); }