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