public async Task FindByTitle() { // given Page expectedPage = _fixture.Create <Page>(); string title = expectedPage.Title; _pageRepositoryMock .GetPageByTitleAsync(title) .Returns(expectedPage); // when ActionResult <PageResponse> actionResult = await _pagesController.FindByTitle(title); // then actionResult.Value.ShouldNotBeNull("ActionResult's ViewModel was null"); actionResult.Value.Title.ShouldBe(title); actionResult.Value.Id.ShouldBe(expectedPage.Id); await _pageRepositoryMock .Received(1) .GetPageByTitleAsync(title); _viewObjectsConverterMock .Received(1) .ConvertToPageResponse(expectedPage); }
public async Task FindByTitle() { // given Page expectedPage = _fixture.Create <Page>(); string title = expectedPage.Title; _pageRepositoryMock .GetPageByTitleAsync(title) .Returns(expectedPage); // when ActionResult <PageResponse> actionResult = await _pagesController.FindByTitle(title); // then PageResponse actualPage = actionResult.GetOkObjectResultValue(); actualPage.Title.ShouldBe(title); actualPage.Id.ShouldBe(expectedPage.Id); }