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