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