Ejemplo n.º 1
0
        public void GetSurveyAsync_WhenSurveyNotFound_ReturnsErrorCode()
        {
            var response = _controller.GetSurveyAsync(_nonMatchingGuid).Result;

            _surveyService.Verify(repo => repo.GetSurveyById(_nonMatchingGuid), Times.Exactly(1));
            Assert.IsType <NotFoundResult>(response);
        }
Ejemplo n.º 2
0
        public async Task GetSurveyAsync_ReturnOneSurve()
        {
            var id     = 5;
            var survey = new Survey {
                Id = id
            };

            _mockMyDbContext.Setup(
                db => db.GetSurveyAsync(id)).Returns(Task.FromResult(survey));

            var surveysController = new SurveysController(_mockMyDbContext.Object);

            var returnedSurvey = (await surveysController.GetSurveyAsync(id)).Value;

            Assert.True(returnedSurvey.Id == id);
        }