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