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); }
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)); }
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); }
public void PageControllerGet() { var results = _ctrl.Get(0, 0); Assert.IsTrue(results.Any()); }