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