コード例 #1
0
        public async Task Get_should_return_from_repository_and_call_converter()
        {
            // given
            Page expectedPage = _fixture.Create <Page>();
            int  id           = expectedPage.Id;

            _pageRepositoryMock
            .GetPageByIdAsync(id)
            .Returns(expectedPage);

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

            // then
            actionResult.Value.ShouldNotBeNull("ActionResult's ViewModel was null");
            actionResult.Value.Id.ShouldBe(id);

            await _pageRepositoryMock
            .Received(1)
            .GetPageByIdAsync(id);

            _viewObjectsConverterMock
            .Received(1)
            .ConvertToPageResponse(expectedPage);
        }
コード例 #2
0
        public void get_should_return_all_pages()
        {
            // Arrange
            _pageService.AddPage(new PageViewModel()
            {
                Id = 1, Title = "new page"
            });
            _pageService.AddPage(new PageViewModel()
            {
                Id = 2, Title = "new page", IsLocked = true
            });

            // Act
            IEnumerable <PageViewModel> pages = _pagesController.Get();

            // Assert
            Assert.That(pages.Count(), Is.EqualTo(2));
        }
コード例 #3
0
        public async Task Get_should_return_page()
        {
            // given
            Page expectedPage = _fixture.Create <Page>();
            int  id           = expectedPage.Id;

            _pageRepositoryMock
            .GetPageByIdAsync(id)
            .Returns(expectedPage);

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

            // then
            actionResult.Value.ShouldNotBeNull("ActionResult's ViewModel was null");
            actionResult.Value.Id.ShouldBe(id);
        }
コード例 #4
0
        public void PageControllerGet()
        {
            var results = _ctrl.Get(0, 0);

            Assert.IsTrue(results.Any());
        }