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