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()); } }
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); } }
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()); } }
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); } }
public TestDbContext() { var options = new DbContextOptionsBuilder <EasyStudingContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; Context = new EasyStudingContext(options); CreateTestDataInDatabase(); }
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>(); }