public async Task <ActionResult <PageResponse> > Get(int id) { Page page = await _pageRepository.GetPageByIdAsync(id); if (page == null) { return(NotFound()); } return(_pageObjectsConverter.ConvertToPageResponse(page)); }
public PagesControllerTests() { _fixture = new Fixture(); _pageRepositoryMock = Substitute.For <IPageRepository>(); _viewObjectsConverterMock = Substitute.For <IPageObjectsConverter>(); _viewObjectsConverterMock .ConvertToPageResponse(Arg.Any <Page>()) .Returns(c => { var page = c.Arg <Page>(); return(new PageResponse() { Id = page.Id, Title = page.Title }); }); _viewObjectsConverterMock .ConvertToPage(Arg.Any <PageRequest>()) .Returns(c => { var pageRequest = c.Arg <PageRequest>(); return(new Page() { Id = pageRequest.Id, Title = pageRequest.Title }); }); _pagesController = new PagesController(_pageRepositoryMock, _viewObjectsConverterMock); }
public TagsControllerTests() { _fixture = new Fixture(); _pageViewModelConverterMock = Substitute.For <IPageObjectsConverter>(); _pageViewModelConverterMock .ConvertToPageResponse(Arg.Any <Page>()) .Returns(callInfo => { var page = callInfo.Arg <Page>(); return(new PageResponse() { Id = page.Id, Title = page.Title }); }); _pageRepositoryMock = Substitute.For <IPageRepository>(); _tagsController = new TagsController(_pageRepositoryMock, _pageViewModelConverterMock); }