示例#1
0
        public void GetAllAsync_WhenNoNamePassed_CallsGetSurveys_ReturnsOk()
        {
            var response = _controller.GetAllAsync(string.Empty).Result;

            _surveyService.Verify(repo => repo.GetSurveys(), Times.Exactly(1));
            _surveyService.Verify(repo => repo.GetSurveysWithNameLike(It.IsAny <string>()), Times.Never);

            Assert.IsType <OkObjectResult>(response);

            var surveys = ((OkObjectResult)response).Value as IList <ISurvey>;

            Assert.NotNull(surveys);
            Assert.Equal(2, surveys.Count);
            Assert.Contains(surveys, p => p.Id == _matchingGuid);
            Assert.Contains(surveys, p => p.Id == _nonMatchingGuid);
        }