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