Example #1
0
        public async Task WebApp_ByName_returns_no_content_status_when_no_parameter_passed()
        {
            _searchApi.Setup(m => m.GetByName(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(NoContentResponse));
            var controller = new SearchController(_searchApi.Object, _logger.Object);

            var result = await controller.ByName("");

            _searchApi.Verify(m => m.GetByName(It.IsAny <string>(), It.IsAny <string>()), Times.Once);
            Assert.IsInstanceOfType(result, typeof(EmptyResult));
        }
Example #2
0
        public async Task WebApp_ByName_returns_error_message_on_wep_api_error()
        {
            _searchApi.Setup(m => m.GetByName(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(FailureResponse));
            var controller = new SearchController(_searchApi.Object, _logger.Object);

            var result = await controller.ByName("vv");

            _searchApi.Verify(m => m.GetByName(It.IsAny <string>(), It.IsAny <string>()), Times.Once);
            Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult));
            Assert.AreEqual(ErrorMessage, ((HttpNotFoundResult)result).StatusDescription);
        }
Example #3
0
        public async Task WebApp_ByName_returns_matching_persons_when_present()
        {
            _searchApi.Setup(m => m.GetByName(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(ByNameSuccessResponse));
            var controller = new SearchController(_searchApi.Object, _logger.Object);

            var result = await controller.ByName("j");

            _searchApi.Verify(m => m.GetByName(It.IsAny <string>(), It.IsAny <string>()), Times.Once);
            Assert.IsInstanceOfType(result, typeof(JsonResult));
            Assert.AreEqual(ThreePeople, ((JsonResult)result).Data);
        }