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