public void TestGetAllCategories()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var repository = new EfDeletableEntityRepository <Skill>(new ApplicationDbContext(options.Options));

            repository.AddAsync(new Skill {
                Name = "title", Content = "test"
            }).GetAwaiter().GetResult();
            repository.SaveChangesAsync().GetAwaiter().GetResult();
            var userSkillRepository =
                new EfRepository <UsersSkill>(new ApplicationDbContext(options.Options));
            var skillsService = new SkillsService(repository, userSkillRepository);

            AutoMapperConfig.RegisterMappings(typeof(MyTest).Assembly);
            var post = skillsService.GetAll <MyTest>(1);

            Assert.Single(skillsService.GetAll <MyTest>());
        }
Exemplo n.º 2
0
        public async Task GetAllReturnsCorrectNumberOfRecords()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.Skills.AddRangeAsync(this.SeedData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <Skill>(context);

            var service = new SkillsService(repository);
            var result  = service.GetAll <EditViewModel>();

            Assert.Equal(2, result.Count());
        }