Exemplo n.º 1
0
        public async void UniversalRepository_Edit_null_should_return_argument_null_exception()
        {
            using (Context = new TestDbContext().Context)
            {
                var rep = new UniversalRepository <Skill>(Context);
                var ex  = await Assert.ThrowsAsync <ArgumentNullException>(async() => await rep.EditAsync(null));

                Assert.Equal(typeof(ArgumentNullException), ex.GetType());
            }
        }
Exemplo n.º 2
0
        public async void UniversalRepository_Get_1_should_return_first_object()
        {
            using (Context = new TestDbContext().Context)
            {
                var rep    = new UniversalRepository <Skill>(Context);
                var result = await rep.GetAsync(1);

                Assert.Equal(1, result.Id);
            }
        }
Exemplo n.º 3
0
        public void UniversalRepository_GetAll_should_return_5_objects()
        {
            using (Context = new TestDbContext().Context)
            {
                var rep    = new UniversalRepository <Skill>(Context);
                var result = rep.GetAll();

                Assert.Equal(5, result.Count());
            }
        }
Exemplo n.º 4
0
        public async void UniversalRepository_Remove_model_should_return_valid_model()
        {
            using (Context = new TestDbContext().Context)
            {
                var rep   = new UniversalRepository <Skill>(Context);
                var model = await rep.RemoveAsync(5);

                Assert.Equal(5, model.Id);
            }
        }
Exemplo n.º 5
0
        public TestDbContext()
        {
            var options = new DbContextOptionsBuilder <EasyStudingContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            Context = new EasyStudingContext(options);

            CreateTestDataInDatabase();
        }
Exemplo n.º 6
0
        public async void UniversalRepository_Add_model_should_return_valid_model()
        {
            using (Context = new TestDbContext().Context)
            {
                var rep   = new UniversalRepository <Skill>(Context);
                var model = await rep.AddAsync(new Skill()
                {
                    Id = 6
                });

                Assert.Equal(6, model.Id);
            }
        }
 public UniversalRepository(EasyStudingContext context)
 {
     _context = context;
     _dbSet   = _context.Set <TEntity>();
 }