public async Task AllPagesCreatedBy_should_call_repository_and_converter()
        {
            // given
            string             username = "******";
            IEnumerable <Page> pages    = _fixture.CreateMany <Page>();

            _pageRepositoryMock
            .FindPagesCreatedByAsync(username)
            .Returns(pages);

            // when
            ActionResult <IEnumerable <PageResponse> > actionResult = await _pagesController.AllPagesCreatedBy(username);

            // then
            var model = (actionResult.Result as OkObjectResult).Value as IEnumerable <PageResponse>;

            model.ShouldNotBeNull("ActionResult's ViewModel was null");
            model.Count().ShouldBe(pages.Count());

            await _pageRepositoryMock
            .Received(1)
            .FindPagesCreatedByAsync(username);

            _viewObjectsConverterMock
            .Received(pages.Count())
            .ConvertToPageResponse(Arg.Any <Page>());
        }
Esempio n. 2
0
        public async Task AllPagesCreatedBy_should_return_pages_for_user()
        {
            // given
            string             username = "******";
            IEnumerable <Page> pages    = _fixture.CreateMany <Page>();

            _pageRepositoryMock
            .FindPagesCreatedByAsync(username)
            .Returns(pages);

            // when
            ActionResult <IEnumerable <PageResponse> > actionResult = await _pagesController.AllPagesCreatedBy(username);

            // then
            actionResult.ShouldBeOkObjectResult();
            IEnumerable <PageResponse> actualPage = actionResult.GetOkObjectResultValue();

            actualPage.Count().ShouldBe(pages.Count());
        }