public async void Delete_Course_Test() { using (var context = new ApplicationDbContext(ContextOptions)) { EFAdminService service = new EFAdminService(context); await service.DeleteCourse(2); Assert.True(context.Courses.ToList().Count == 1); Assert.True(context.Courses.ToList()[0].CourseId == 1); } }
public async void Delete_Schedule_Test() { using (var context = new ApplicationDbContext(ContextOptions)) { EFAdminService service = new EFAdminService(context); await service.DeleteSchedule(1); Assert.Equal(1, context.Schedules.ToList().Count); Assert.True(context.Schedules.ToList()[0].ScheduleId == 2 && context.Schedules.ToList()[0].DayOfWeek == DayOfWeek.Tuesday); } }
public async void Get_All_Courses_Test() { using (var context = new ApplicationDbContext(ContextOptions)) { EFAdminService service = new EFAdminService(context); var Courses = await service.GetAllCourses(); Assert.Equal(2, Courses.Count()); Assert.True(Courses.ToList()[0].CourseName == "sssss" && context.Courses.ToList()[0].CourseId == 1); Assert.True(Courses.ToList()[1].CourseName == "xxxx" && context.Courses.ToList()[1].CourseId == 2); } }
public void Get_All_Schedules_Test() { using (var context = new ApplicationDbContext(ContextOptions)) { EFAdminService service = new EFAdminService(context); var Schedules = service.GetAllSchedules().Result; Assert.Equal(2, Schedules.Count()); Assert.True(Schedules.ToList()[0].ScheduleId == 1 && Schedules.ToList()[0].DayOfWeek == DayOfWeek.Wednesday); Assert.True(Schedules.ToList()[1].ScheduleId == 2 && Schedules.ToList()[1].DayOfWeek == DayOfWeek.Tuesday); } }
//[Fact] public async void Add_Student_Test() { using (var context = new ApplicationDbContext(ContextOptions)) { EFAdminService service = new EFAdminService(context); StudentUser s5 = new StudentUser() { Id = "S5-rr-4d", Name = "Stud5", Email = "*****@*****.**", Password = "******", ConfirmPassword = "******", PhoneNumber = "999999" }; await service.AddStudent(s5); Assert.Equal(5, context.StudentUsers.ToList().Count()); //Assert.True(context.StudentUsers.ToList()[2].Id == "S3"); } }
public async void Update_Schedule_Test() { using (var context = new ApplicationDbContext(ContextOptions)) { EFAdminService service = new EFAdminService(context); Schedule sc1 = new Schedule() { ScheduleId = 1, DayOfWeek = DayOfWeek.Monday, StartTime = new DateTime(2021, 05, 27, 8, 0, 0), EndTime = new DateTime(2021, 05, 27, 10, 0, 0) }; await service.UpdateScheduleAsync(sc1); Assert.True(context.Schedules.ToList()[0].ScheduleId == 1 && context.Schedules.ToList()[0].DayOfWeek == DayOfWeek.Monday); } }
public void Add_Schedule_Test() { using (var context = new ApplicationDbContext(ContextOptions)) { EFAdminService service = new EFAdminService(context); Schedule sc3 = new Schedule() { ScheduleId = 3, DayOfWeek = DayOfWeek.Thursday, StartTime = new DateTime(2021, 05, 27, 8, 0, 0), EndTime = new DateTime(2021, 05, 27, 10, 0, 0) }; service.AddSchedule(sc3); Assert.Equal(3, context.Schedules.ToList().Count()); Assert.True(context.Schedules.ToList()[2].ScheduleId == 3); } }
public async void Update_CourseWithStudent_Test() { using (var context = new ApplicationDbContext(ContextOptions)) { EFAdminService service = new EFAdminService(context); context.StudentUsers.Add(new StudentUser() { Id = "testst", Name = "Stud1", Email = "*****@*****.**", Password = "******", ConfirmPassword = "******" }); Course c1 = new Course() { CourseId = 1, CourseName = "TEST", Duration = 1, TeacherUserId = "test" }; await service.UpdateCourseAsync(c1, "testst"); Assert.True(context.Courses.ToList()[0].CourseId == 1 && context.Courses.ToList()[0].CourseName == "TEST" && context.Courses.ToList()[0].Duration == 1); // && context.Courses.ToList()[0].StudentUsers.ToList()[2].Id == "testst" } }
public async void Update_Course_Test() { using (var context = new ApplicationDbContext(ContextOptions)) { EFAdminService service = new EFAdminService(context); TeacherUser t1 = new TeacherUser() { Id = "ttttttt", Email = "*****@*****.**" }; Course c1 = new Course() { CourseId = 1, CourseName = "TEST", Duration = 1, TeacherUserId = "test" }; await service.UpdateCourseAsync(c1); Assert.True(context.Courses.ToList()[0].CourseId == 1 && context.Courses.ToList()[0].CourseName == "TEST" && context.Courses.ToList()[0].Duration == 1 && context.Courses.ToList()[0].TeacherUserId == "test"); } }
public void Add_Course_Test() { using (var context = new ApplicationDbContext(ContextOptions)) { EFAdminService service = new EFAdminService(context); TeacherUser t1 = new TeacherUser() { Id = "ttttttt", Name = "teacher1", Email = "*****@*****.**" }; Course c1 = new Course() { CourseId = 3, CourseName = "zzzz", Duration = 900, TeacherUserId = "ttttttt" }; service.AddCourse(c1); Assert.Equal(3, context.Courses.ToList().Count()); Assert.True(context.Courses.ToList()[2].CourseName == "zzzz"); } }