Пример #1
0
        public async Task ShouldReturnOkObjectResult()
        {
            var options = SqliteInMemory.CreateOptions <SurveyDbContext>();

            using (var context = new SurveyDbContext(options))
            {
                context.Database.EnsureCreated();
                context.SeedDataBaseWithSurveys();

                var controller = new TestController();
                var surveys    = EfTestData.CreateSurveys();

                var mockService = new Mock <IListSurveysService>();
                mockService.Setup(m => m.GetSurveys()).Returns((Task.FromResult((surveys))));

                var result = await controller.GetListOfSurveys(mockService.Object);

                result.ShouldNotBeNull();
                result.ShouldEqual(result as OkObjectResult);

                var r = result as OkObjectResult;

                r.Value.ShouldEqual(surveys);
            }
        }