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