Exemplo n.º 1
0
        public async Task <IActionResult> GetSearchContent(SeoRankSearch searchParams)
        {
            var content = await _manager.GetSearchContent(searchParams.Search);

            if (content == null)
            {
                return(NotFound(new ErrorResponse(404, $"Content could not be found.")));
            }
            return(Ok(content));
        }
Exemplo n.º 2
0
        public async void GetSearchContent_ReturnsNotFound_WhenNullResponse()
        {
            string content = null;

            _mockManager.Setup(x => x.GetSearchContent(It.IsAny <string>())).ReturnsAsync(content);

            var search = new SeoRankSearch {
                Search = "a very random dskahfisa search ndkosahfoaslg"
            };
            IActionResult result = await _controller.GetSearchContent(search);

            var objectResult = Assert.IsType <NotFoundObjectResult>(result);
        }
Exemplo n.º 3
0
        public async void GetSearchContent_ReturnsCorrectString(string content)
        {
            _mockManager.Setup(x => x.GetSearchContent(It.IsAny <string>())).ReturnsAsync(content);

            var search = new SeoRankSearch {
                Search = "online title search"
            };
            IActionResult result = await _controller.GetSearchContent(search);

            var objectResult = Assert.IsType <OkObjectResult>(result);

            Assert.Equal(objectResult.Value, content);
        }