public async Task FindByTag_should_use_repository_to_find_tags() { // given string tag = "gutentag"; List <Page> pagesWithTag = _fixture.CreateMany <Page>().ToList(); pagesWithTag[0].Tags += $", {tag}"; pagesWithTag[1].Tags += $", {tag}"; pagesWithTag[2].Tags += $", {tag}"; _pageRepositoryMock .FindPagesContainingTagAsync(tag) .Returns(pagesWithTag); // when IEnumerable <PageResponse> pageViewModelsWithTag = await _tagsController.FindPageWithTag(tag); // then pageViewModelsWithTag.Count().ShouldBe(pagesWithTag.Count()); _pageViewModelConverterMock .Received(pagesWithTag.Count) .ConvertToPageResponse(Arg.Any <Page>()); }
public async Task FindPageWithTag_should_return_pages() { // given string tag = "gutentag"; List <Page> pagesWithTag = _fixture.CreateMany <Page>().ToList(); pagesWithTag[0].Tags += $", {tag}"; pagesWithTag[1].Tags += $", {tag}"; pagesWithTag[2].Tags += $", {tag}"; _pageRepositoryMock .FindPagesContainingTagAsync(tag) .Returns(pagesWithTag); // when ActionResult <IEnumerable <PageResponse> > actionResult = await _tagsController.FindPageWithTag(tag); // then actionResult.ShouldBeOkObjectResult(); IEnumerable <PageResponse> response = actionResult.GetOkObjectResultValue(); response.Count() .ShouldBe(pagesWithTag.Count()); }