public async Task AnimalFactsTests_FactsReturnsOne(FactSubject factSubject) { var oneFact = await _facts.GetFact(new AnimalFactQuery(factSubject, 10)); Assert.IsTrue(oneFact is Fact); Assert.IsNotNull(oneFact); Assert.IsTrue(_fakeFacts.Any(x => x.Id == oneFact.Id)); }
public async Task AnimalFactsTests_HandlesExceptionReturnsNull(FactSubject factSubject) { var mockMessageHandler = new Mock <HttpMessageHandler>(); mockMessageHandler.Protected() .Setup <Task <HttpResponseMessage> >( "SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>() ) .ThrowsAsync(new Exception("No cat facts for you.")); _facts = new AnimalFacts(new HttpClient(mockMessageHandler.Object)); var oneFact = await _facts.GetFact(new AnimalFactQuery(factSubject, 10)); Assert.IsTrue(oneFact is null); }