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