Ejemplo n.º 1
0
        public async void CourseControllerTest()
        {
            var options = new DbContextOptionsBuilder <AppDbContext>()
                          .UseInMemoryDatabase(databaseName: "yeet").Options;

            using (var context = new AppDbContext(options))
            {
                Repository repo = new Repository(context);
                var        _CourseController = new CourseController(repo);
                Course     tempCourseOne     = new Course();
                tempCourseOne.Title = "first";

                Course tempCourseTwo = new Course();
                tempCourseOne.Title = "second";
                await _CourseController.CreateCourseAsync(tempCourseOne);

                await _CourseController.CreateCourseAsync(tempCourseTwo);

                ActionResult <List <Course> > testList = _CourseController.GetAll().Result;
                testList = testList.Value;
                Assert.NotNull(testList);
                ActionResult <Course> testList2 = _CourseController.Get(1).Result;
                Assert.NotNull(testList2);
                tempCourseOne.Title = "third";
                await repo.EditCourseScoreAsync(tempCourseOne);

                Assert.Equal("third", (repo.GetCourseAsync(1).Result.Title));
            }
        }