Example #1
0
        public async Task <ActionResult <PageResponse> > Get(int id)
        {
            Page page = await _pageRepository.GetPageByIdAsync(id);

            if (page == null)
            {
                return(NotFound());
            }

            return(_pageObjectsConverter.ConvertToPageResponse(page));
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }