public async void WhenServerTimeoutErrorOccurs_TimeoutExceptionThrown() { // Arrange var httpClient = FakeHttpClientFactory.CreateFakeHttpClientForTimeout(); StockQuoteClient client = new StockQuoteClient(httpClient); // Act and Assert var result = await Assert.ThrowsAsync <TimeoutException>(() => client.GetStockQuote("ZVZZT")); }
public async void WhenInternalServerError_UnknownTickerSymbolExceptionThrown() { // Arrange var httpClient = FakeHttpClientFactory.CreateFakeHttpClientForStringContent(HttpStatusCode.InternalServerError, "text/plain", "Internal Server Error"); StockQuoteClient client = new StockQuoteClient(httpClient); // Act and Assert var result = await Assert.ThrowsAsync <ApplicationException>(() => client.GetStockQuote("ZVZZT")); }
public async void WhenTickerSymbolNotFound_UnknownTickerSymbolExceptionThrown() { // Arrange var httpClient = FakeHttpClientFactory.CreateFakeHttpClientForStringContent(HttpStatusCode.NotFound, "text/plain", "Symbol not found"); StockQuoteClient client = new StockQuoteClient(httpClient); // Act and Assert var result = await Assert.ThrowsAsync <UnknownTickerSymbolException>(() => client.GetStockQuote("ZVZZT")); Assert.Equal("ZVZZT", result.TickerSymbol); }
public async void TestStockTickerGoodResult() { // Arrange var httpClient = FakeHttpClientFactory.CreateFakeHttpClientForJsonStringContent(HttpStatusCode.OK, AAPL_QUOTE); StockQuoteClient client = new StockQuoteClient(httpClient); // Act var result = await client.GetStockQuote("AAPL"); // Assert Assert.Equal("AAPL", result.Symbol); }