public void TestAllPositiveUsers() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var repository = new EfDeletableEntityRepository <ApplicationUser>(new ApplicationDbContext(options.Options)); var studentEfRepository = new EfRepository <StudentJob>(new ApplicationDbContext(options.Options)); var userSkillRepository = new EfRepository <UsersSkill>(new ApplicationDbContext(options.Options)); var jobRepository = new EfDeletableEntityRepository <Job>(new ApplicationDbContext(options.Options)); var jobService = new JobsService(jobRepository, studentEfRepository); var skillRepository = new EfDeletableEntityRepository <Skill>(new ApplicationDbContext(options.Options)); var skillService = new SkillsService(skillRepository, userSkillRepository); var user = new ApplicationUser { Description = "test", Type = UserType.Employer, }; repository.AddAsync(user).GetAwaiter().GetResult(); repository.SaveChangesAsync().GetAwaiter().GetResult(); var usersService = new ApplicationUsersService(repository, jobService, studentEfRepository, jobRepository, skillService, userSkillRepository, skillRepository); AutoMapperConfig.RegisterMappings(typeof(CompaniesServiceTests.MyTest).Assembly); Assert.Single(usersService.GetAll <CompaniesServiceTests.MyTest>()); repository.Delete(user); repository.SaveChangesAsync().GetAwaiter().GetResult(); }
public void TestNoUsers() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var repository = new EfDeletableEntityRepository <ApplicationUser>(new ApplicationDbContext(options.Options)); var studentEfRepository = new EfRepository <StudentJob>(new ApplicationDbContext(options.Options)); var userSkillRepository = new EfRepository <UsersSkill>(new ApplicationDbContext(options.Options)); var jobRepository = new EfDeletableEntityRepository <Job>(new ApplicationDbContext(options.Options)); var jobService = new JobsService(jobRepository, studentEfRepository); var skillRepository = new EfDeletableEntityRepository <Skill>(new ApplicationDbContext(options.Options)); var skillService = new SkillsService(skillRepository, userSkillRepository); var usersService = new ApplicationUsersService(repository, jobService, studentEfRepository, jobRepository, skillService, userSkillRepository, skillRepository); AutoMapperConfig.RegisterMappings(typeof(CompaniesServiceTests.MyTest).Assembly); Assert.Empty(usersService.GetAll <CompaniesServiceTests.MyTest>()); }