public async Task UserAddTestAsync()
        {
            var options = new DbContextOptionsBuilder <OlpContext>()
                          .UseInMemoryDatabase(databaseName: "UserAddTest")
                          .Options;

            using (var context = new OlpContext(options))
            {
                Domain.Student student = new Domain.Student()
                {
                    FirstName = "Daniel",
                    LastName  = "Zeimo",
                    Email     = "*****@*****.**",
                };

                var service = new UserService(context);
                await service.Create(student);

                Domain.User fetchedUser = await service.FindBy(x => x.FirstName == student.FirstName);

                Assert.AreEqual(fetchedUser.FirstName, student.FirstName);

                Console.Write("User was : " + student.FirstName + " successfully added");
            }
        }
예제 #2
0
        public async System.Threading.Tasks.Task AddTeacher_ToCourse_TestAsync()
        {
            var options = new DbContextOptionsBuilder <OlpContext>()
                          .UseInMemoryDatabase(databaseName: "Add_writes_to_database_TeacherCourses")
                          .Options;

            // Run the test against one instance of the context
            using (var context = new OlpContext(options))
            {
                Teacher teacher = new Domain.Teacher()
                {
                    FirstName = "Test Name",
                    LastName  = "Test last name",
                    Email     = "test email",
                };

                var teacherService = new TeacherService(context);
                await teacherService.Create(teacher);

                Teacher fecthedTeacher = await teacherService.FindBy(x => x.FirstName == teacher.FirstName);

                Assert.AreEqual(fecthedTeacher.FirstName, teacher.FirstName);

                Course course = new Domain.Course()
                {
                    Name        = "Test course name",
                    Description = "test course desc",
                };

                var courseService = new CourseService(context);
                await courseService.Create(course);

                Course fecthedCourse = await courseService.FindBy(x => x.Name == course.Name);

                Assert.AreEqual(fecthedCourse.Name, course.Name);

                //teacher.TeacherCourses.Add(course);

                TeacherCourse teacherCourse = new TeacherCourse()
                {
                    Course  = course,
                    Teacher = teacher
                };

                context.Add(teacherCourse);
                context.SaveChanges();

                TeacherCourse fecthedTeacherCourse = context.TeacherCourses.FirstOrDefaultAsync().Result;

                Assert.AreEqual(fecthedTeacherCourse.Teacher.UserId, teacher.UserId);

                fecthedCourse = await courseService.FindBy(x => x.Name == course.Name);

                Assert.AreEqual(fecthedCourse.TeacherCourses.Count, 1);

                //Assert.AreEqual(teacher.TeacherCourses, teacherCourse.Course);
            }
        }
 public SeederManager(OlpContext context)
 {
     // Add all seeders here
     new GroupSeeder(context).Run();
     new CourseSeeder(context).Run();
     new ModuleSeeder(context).Run();
     new RecordSeeder(context).Run();
     new StudentSeeder(context).Run();
     new TeacherSeeder(context).Run();
 }
        public void SeederManagerRunTest()
        {
            var options = new DbContextOptionsBuilder <OlpContext>()
                          .UseInMemoryDatabase(databaseName: "Add_writes_to_database_SeederManager")
                          .Options;

            using (var context = new OlpContext(options))
            {
                var SeederManager = new SeederManager(context);
            }
        }
        public async Task OneToManyStudentGroupTestAsync()
        {
            var options = new DbContextOptionsBuilder <OlpContext>()
                          .UseInMemoryDatabase(databaseName: "UserGroupTest")
                          .Options;

            // Run the test against one instance of the context
            using (var context = new OlpContext(options))
            {
                Domain.Group group = new Domain.Group()
                {
                    GroupId     = 1,
                    Name        = "PI15B",
                    Description = "make viko great again"
                };

                var groupService = new GroupService(context);
                await groupService.Create(group);

                Domain.Group fecthedGroup = await groupService.FindBy(x => x.Name == group.Name);

                Assert.AreEqual(fecthedGroup.Name, group.Name);
                Console.Write("Group  : " + group.Name + " successfully added");

                //user insert
                Domain.Student student = new Domain.Student()
                {
                    GroupId   = 1,
                    FirstName = "Daniel",
                    LastName  = "Zeimo",
                    Email     = "*****@*****.**"
                };

                var studentService = new StudentService(context);
                await studentService.Create(student);

                Domain.Student fetchedUser = await studentService.FindBy(x => x.FirstName == student.FirstName);

                Assert.AreEqual(fetchedUser.FirstName, student.FirstName);
                Assert.AreEqual(group.Name, fetchedUser.Group.Name);
                Console.Write("|User  : "******" successfully added");
                Console.Write("|User group : " + fetchedUser.Group.Name + " Description" + fetchedUser.Group.Description);
            }
        }
예제 #6
0
        public async Task GroupAddTestAsync()
        {
            var options = new DbContextOptionsBuilder <OlpContext>()
                          .UseInMemoryDatabase(databaseName: "Add_writes_to_database_ADD")
                          .Options;

            // Run the test against one instance of the context
            using (var context = new OlpContext(options))
            {
                Domain.Group group = new Domain.Group()
                {
                    Name        = "Test1",
                    Description = "test desc1"
                };

                var service = new GroupService(context);
                await service.Create(group);

                Domain.Group fecthedGroup = await service.FindBy(x => x.Name == group.Name);

                Assert.AreEqual(fecthedGroup.Name, group.Name);
                Console.Write("Group was : " + group.Name + " successfully added");
            }
        }
 public ChatSessionService(OlpContext context) : base(context) { }
 public StudentSeeder(OlpContext context) : base(context)
 {
 }
 public RecordSeeder(OlpContext context) : base(context)
 {
 }
예제 #10
0
 public GroupsController(OlpContext context, IGroupService groupService)
 {
     _context      = context;
     _groupService = groupService;
 }
예제 #11
0
 public ExerciseService(OlpContext context) : base(context)
 {
 }
예제 #12
0
 public UserService(OlpContext context) : base(context)
 {
 }
예제 #13
0
 public ChatBotService(OlpContext context) : base(context)
 {
 }
 public CourseService(OlpContext context) : base(context)
 {
 }
 public UsersController(OlpContext context)
 {
     _context = context;
 }
 public RecordService(OlpContext context) : base(context)
 {
 }
예제 #17
0
 public Seeder(OlpContext context)
 {
     _context  = context;
     _entities = context.Set <T>();
 }
 public StudentService(OlpContext context) : base(context)
 {
 }
 public TeacherSeeder(OlpContext context) : base(context)
 {
 }
예제 #20
0
 protected Service(OlpContext context)
 {
     _context = context;
 }
예제 #21
0
 public GroupSeeder(OlpContext context) : base(context)
 {
 }
 public TeacherService(OlpContext context) : base(context)
 {
 }
예제 #23
0
 public CourseSeeder(OlpContext context) : base(context)
 {
 }
 public ModuleService(OlpContext context) : base(context)
 {
 }
 protected GenericService(OlpContext context) : base(context)
 {
     _context  = context;
     _entities = context.Set <T>();
 }
 public ModuleSeeder(OlpContext context) : base(context)
 {
 }
예제 #27
0
 public GroupService(OlpContext context) : base(context)
 {
 }