コード例 #1
0
        public async Task FindHomePage_should_return_first_page_with_homepage_tag()
        {
            // given
            List <Page> pages = _fixture.CreateMany <Page>(10).ToList();

            for (int i = 0; i < pages.Count; i++)
            {
                pages[i].Tags += ", homepage";
                pages[i].Title = $"page {i}";
            }

            _pageRepositoryMock
            .FindPagesContainingTagAsync("homepage")
            .Returns(pages);

            // when
            ActionResult <PageResponse> actionResult = await _pagesController.FindHomePage();

            // then
            actionResult.Value.ShouldNotBeNull("ActionResult's ViewModel was null");
            actionResult.Value.Title.ShouldBe("page 0");
            actionResult.Value.Id.ShouldBe(pages[0].Id);

            await _pageRepositoryMock
            .Received(1)
            .FindPagesContainingTagAsync("homepage");

            _viewObjectsConverterMock
            .Received(1)
            .ConvertToPageResponse(pages[0]);
        }
コード例 #2
0
        public async Task FindHomePage_should_return_first_page_with_homepage_tag()
        {
            // given
            List <Page> pages = _fixture.CreateMany <Page>(10).ToList();

            for (int i = 0; i < pages.Count; i++)
            {
                pages[i].Tags += ", homepage";
                pages[i].Title = $"page {i}";
            }

            _pageRepositoryMock
            .FindPagesContainingTagAsync("homepage")
            .Returns(pages);

            // when
            ActionResult <PageResponse> actionResult = await _pagesController.FindHomePage();

            // then
            PageResponse actualPage = actionResult.GetOkObjectResultValue();

            actualPage.Title.ShouldBe("page 0");
            actualPage.Id.ShouldBe(pages[0].Id);
        }