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