예제 #1
0
        public void GetTeachersShouldReturnCollectionOfTeachers()
        {
            var dbOptions = new DbContextOptionsBuilder <ApplicationDbContext>()
                            .UseInMemoryDatabase("test");
            var context = new ApplicationDbContext(dbOptions.Options);

            var rolesService   = new WebSchool.Services.RolesService(context);
            var linksService   = new LinksService(context);
            var usersService   = new UsersService(context, rolesService, linksService);
            var classesService = new ClassesService(context, usersService, rolesService);
            var teacherService = new TeacherService(context, classesService, rolesService);

            var result = teacherService.GetTeachers("id");

            Assert.True(result.Count == 0);
        }
예제 #2
0
        public void GetTeacherShouldReturnNullWhenTeacherIsMissing()
        {
            var dbOptions = new DbContextOptionsBuilder <ApplicationDbContext>()
                            .UseInMemoryDatabase("test");
            var context = new ApplicationDbContext(dbOptions.Options);

            var rolesService   = new WebSchool.Services.RolesService(context);
            var linksService   = new LinksService(context);
            var usersService   = new UsersService(context, rolesService, linksService);
            var classesService = new ClassesService(context, usersService, rolesService);
            var teacherService = new TeacherService(context, classesService, rolesService);

            var result = teacherService.GetTeacher("id");

            Assert.Null(result);
        }
예제 #3
0
        public async Task GetStudentIdsWithMatchingEmailShouldReturnStudents()
        {
            var dbOptions = new DbContextOptionsBuilder <ApplicationDbContext>()
                            .UseInMemoryDatabase("test");
            var context = new ApplicationDbContext(dbOptions.Options);

            var roleService     = new WebSchool.Services.RolesService(context);
            var studentsService = new StudentsService(context, roleService);

            var school = new School();
            await context.Schools.AddAsync(school);

            await context.SaveChangesAsync();

            var students = studentsService.GetStudentIdsWithMatchingEmail("email", "12 D", school.Id);

            Assert.That(students.Count == 0);
        }