public async void Get() { Mock <ILogger <TeacherSkillRepository> > loggerMoc = TeacherSkillRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TeacherSkillRepositoryMoc.GetContext(); var repository = new TeacherSkillRepository(loggerMoc.Object, context); TeacherSkill entity = new TeacherSkill(); context.Set <TeacherSkill>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); record.Should().NotBeNull(); }
public async void Update_Entity_Is_Tracked() { Mock <ILogger <TeacherSkillRepository> > loggerMoc = TeacherSkillRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TeacherSkillRepositoryMoc.GetContext(); var repository = new TeacherSkillRepository(loggerMoc.Object, context); TeacherSkill entity = new TeacherSkill(); context.Set <TeacherSkill>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); await repository.Update(record); var modifiedRecord = context.Set <TeacherSkill>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }
public async void Update_Entity_Is_Tracked() { Mock <ILogger <TeacherSkillRepository> > loggerMoc = TeacherSkillRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TeacherSkillRepositoryMoc.GetContext(); var repository = new TeacherSkillRepository(loggerMoc.Object, context); TeacherSkill entity = new TeacherSkill(); entity.SetProperties(default(int), "B"); context.Set <TeacherSkill>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); await repository.Update(record); var records = await context.Set <TeacherSkill>().ToListAsync(); records.Count.Should().Be(2); }