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