public void WhenTwoPages_WithThreeCards_AllAreReturned() { var maxPageProvider = Mock.Of <IMaxPageProvider>(provider => provider.GetMaxPage() == 2); var cardDetailsFetcher = Mock.Of <ICardDetailsFetcher>(fetcher => fetcher.GetCardDetails(1) == new List <CardInfoDto> { new CardInfoDto(), new CardInfoDto() }); var sut = new CardsInfoRetriever(); Assert.AreEqual(2, sut.GetCardsInfo(maxPageProvider, cardDetailsFetcher, new PageRangeDto()).Count); }
public void WhenNoCards_EmptyListIsReturned() { var sut = new CardsInfoRetriever(); var maxPageProvider = Mock.Of <IMaxPageProvider>(provider => provider.GetMaxPage() == 0); var cardDetailsFetcher = Mock.Of <ICardDetailsFetcher>(fetcher => fetcher.GetCardDetails(1) == new List <CardInfoDto> { new CardInfoDto(), new CardInfoDto() } && fetcher.GetCardDetails(2) == new List <CardInfoDto> { new CardInfoDto() }); Assert.AreEqual(0, sut.GetCardsInfo(maxPageProvider, cardDetailsFetcher, new PageRangeDto()).Count); }
public void WhenIncorrectMaxRange_ItIsSetToTheOneProvidedByMaxRangeProvider(int maxRange) { var sut = new CardsInfoRetriever(); var maxPageProvider = Mock.Of <IMaxPageProvider>(provider => provider.GetMaxPage() == 2); var cardDetailsFetcher = Mock.Of <ICardDetailsFetcher>(fetcher => fetcher.GetCardDetails(1) == new List <CardInfoDto> { new CardInfoDto(), new CardInfoDto() } && fetcher.GetCardDetails(2) == new List <CardInfoDto> { new CardInfoDto() }); Assert.AreEqual(3, sut.GetCardsInfo(maxPageProvider, cardDetailsFetcher, new PageRangeDto { Max = maxRange }).Count); }
public void WhenPageRangeRequested_ItsDataIsReturned(PageRangeDto pageRange, int expectedCardsCount) { var sut = new CardsInfoRetriever(); var maxPageProvider = Mock.Of <IMaxPageProvider>(provider => provider.GetMaxPage() == 3); var cardDetailsFetcher = Mock.Of <ICardDetailsFetcher>(fetcher => fetcher.GetCardDetails(1) == new List <CardInfoDto> { new CardInfoDto(), new CardInfoDto() } && fetcher.GetCardDetails(2) == new List <CardInfoDto> { new CardInfoDto() } && fetcher.GetCardDetails(3) == new List <CardInfoDto> { new CardInfoDto(), new CardInfoDto(), new CardInfoDto() }); Assert.AreEqual(expectedCardsCount, sut.GetCardsInfo(maxPageProvider, cardDetailsFetcher, pageRange).Count); }