public async void Get() { Mock <ILogger <TeacherRepository> > loggerMoc = TeacherRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TeacherRepositoryMoc.GetContext(); var repository = new TeacherRepository(loggerMoc.Object, context); Teacher entity = new Teacher(); context.Set <Teacher>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); record.Should().NotBeNull(); }
public async void Delete() { Mock <ILogger <TeacherRepository> > loggerMoc = TeacherRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TeacherRepositoryMoc.GetContext(); var repository = new TeacherRepository(loggerMoc.Object, context); Teacher entity = new Teacher(); context.Set <Teacher>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.Id); Teacher modifiedRecord = await context.Set <Teacher>().FirstOrDefaultAsync(); modifiedRecord.Should().BeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <TeacherRepository> > loggerMoc = TeacherRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TeacherRepositoryMoc.GetContext(); var repository = new TeacherRepository(loggerMoc.Object, context); Teacher entity = new Teacher(); context.Set <Teacher>().Add(entity); await context.SaveChangesAsync(); await repository.Update(new Teacher()); var modifiedRecord = context.Set <Teacher>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }