public void TestImportProducts() { var products = new[] { new Product { Name = "Test Product A " + Guid.NewGuid(), Description = "Test Description A", Price = 1, IsFeatured = false, IsPublished = false }, new Product { Name = "Test Product B " + Guid.NewGuid(), Description = "Test Description B", Price = 2, IsFeatured = false, IsPublished = false }, new Product { Name = "Test Product C " + Guid.NewGuid(), Description = "Test Description C", Price = 3, IsFeatured = false, IsPublished = false } }; var svc = new ProductImportService(); var newProductIds = svc.ImportProducts(products); var testDbContext = new GenericDBContext(); foreach (var productId in newProductIds) { var actual = testDbContext.Products.Count(p => p.ProductId == productId); Assert.AreEqual(1, actual); } testDbContext.Dispose(); }
public void TestImportProductSimple() { var newProduct = new Product { ProductId = 0, Name = "Test Product " + Guid.NewGuid(), Description = "Test Description", Price = 1, IsFeatured = false, IsPublished = false }; var svc = new ProductImportService(); var newProductId = svc.ImportProductSimple(newProduct); var testDbContext = new GenericDBContext(); Assert.AreEqual(1, testDbContext.Products.Count(p => p.ProductId == newProductId)); testDbContext.Dispose(); }