Exemple #1
0
        public async Task GetSurveysAsync_ReturnAListOfSurves()
        {
            var expectedSurveys = MyDbContext.GetSeedingSurveys();

            _mockMyDbContext.Setup(
                db => db.GetSurveysAsync()).Returns(Task.FromResult(expectedSurveys));

            var surveysController = new SurveysController(_mockMyDbContext.Object);

            var result = await surveysController.GetSurveysAsync();

            var actualSurveys = Assert.IsAssignableFrom <ActionResult <IEnumerable <Survey> > >(result).Value;

            Assert.Equal(
                expectedSurveys.OrderBy(s => s.Id).Select(s => s.Title),
                actualSurveys.OrderBy(s => s.Id).Select(s => s.Title));
        }