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