public void UpdateProductTest() { using (var scope = new TransactionScope()) { var category = CreateCategory(categoryName); var product = CreateProduct(productName, productPrice, productDate, productQuantity, category.categoryId); var productFind = productDao.Find(product.productId); // Check data Assert.AreEqual(productName, productFind.productName); Assert.AreEqual(productPrice, productFind.productPrice); Assert.AreEqual(productDate, productFind.productDate); Assert.AreEqual(productQuantity, productFind.productQuantity); Assert.AreEqual(category.categoryId, productFind.categoryId); string name = "update1"; decimal price = 12; int quantity = 13; productService.UpdateProductDetails(product.productId, name, price, quantity); productFind = productDao.Find(product.productId); // Check data Assert.AreEqual(name, productFind.productName); Assert.AreEqual(price, productFind.productPrice); Assert.AreEqual(productDate, productFind.productDate); Assert.AreEqual(quantity, productFind.productQuantity); Assert.AreEqual(category.categoryId, productFind.categoryId); } }
public void FindByKeyWordsTest() { using (TransactionScope scope = new TransactionScope()) { // Create a category long categoryId = CreateCategory("Music"); // Create a product long productId = CreateProduct(categoryId, "Dire Straits", 10, (float)8.65); // Find by keywords List <ProductDetails> products = productService.FindByKeywords("dire", 0, 2); Product product = productDao.Find(productId); // Check the data Assert.AreEqual(productId, products[0].productId); Assert.AreEqual(product.categoryId, products[0].categoryId); Assert.AreEqual(product.name, products[0].name); Assert.AreEqual(product.numberOfUnits, products[0].numberOfUnits); Assert.AreEqual(product.prize, products[0].prize); } }
public void TagProductTest() { using (TransactionScope scope = new TransactionScope()) { // Create Category long categoryId = CreateCategory("Music"); // Create Product long productId = CreateProduct(categoryId, "ACDC", 10, (float)10.5); // Create Tag long tagId = CreateTag("Rock", 0); // Tag a product tagService.TagProduct(productId, tagId); // Check the data Tag tag = tagDao.Find(tagId); Assert.AreEqual(tag.timesUsed, 1); Assert.AreEqual(tag.Products.ElementAt(0).productId, productId); Assert.AreEqual(productDao.Find(productId).Tags.ElementAt(0).tagId, tagId); } }