public void ReturnMostExpensiveProduct() { string name = "Butter"; int quantity = 10; decimal price = 100m; string name2 = "Bread"; int quantity2 = 5; decimal price2 = 150m; string name3 = "Meat"; int quantity3 = 10; decimal price3 = 200m; Product product = new Product(name, quantity, price); Product product2 = new Product(name2, quantity2, price2); Product product3 = new Product(name3, quantity3, price3); StoreManager manager = new StoreManager(); manager.AddProduct(product); manager.AddProduct(product2); manager.AddProduct(product3); List <Product> orderedProducts = manager.Products.OrderByDescending(x => x.Price).ToList(); Product expectedMostExpensive = orderedProducts[0]; Product actualMostExpensive = manager.GetTheMostExpensiveProduct(); Assert.That(actualMostExpensive.Price == expectedMostExpensive.Price); Assert.That(actualMostExpensive.Name == expectedMostExpensive.Name); Assert.That(actualMostExpensive.Quantity == expectedMostExpensive.Quantity); }
public void AddProductShgouldThrowNullExceptionWhenAddingNullProduct() { StoreManager sm = new StoreManager(); Product product = new Product("Lenovo", 100, 1500.50m); sm.AddProduct(product); Assert.Throws <ArgumentNullException>(() => sm.AddProduct(null)); }
public void Add_Product_Should_Throw_An_Exception_If_The_Product_Quantity_Is_Bellow_Zero() { var storeManager = new StoreManager(); storeManager.AddProduct(new Product("Pizza", 10, 0.1m)); Assert.Throws <ArgumentException>( () => storeManager.AddProduct(new Product("Pizza", -10, 0.1m)), "The product qty is not bellow zero."); }
public void Add_Product_Should_Throw_An_Exception_If_The_Product_Is_Null() { var storeManager = new StoreManager(); storeManager.AddProduct(new Product("Pizza", 10, 0.1m)); Assert.Throws <ArgumentNullException>( () => storeManager.AddProduct(null), "The product is not null."); }
public void BuyProductShgouldThrowExcQuantity() { StoreManager sm = new StoreManager(); Product product = new Product("Lenovo", 100, 1500.50m); Product product2 = new Product("Lenovoooooo", 100000, 150000.50m); sm.AddProduct(product); sm.AddProduct(product2); Assert.Throws <ArgumentException>(() => sm.BuyProduct("Lenovo", 10000000)); }
public void BuyProductQuantityBeCorrect() { StoreManager sm = new StoreManager(); Product product = new Product("Lenovo", 100, 1500m); Product product2 = new Product("Lenovoooooo", 100000, 150000.50m); sm.AddProduct(product); sm.AddProduct(product2); sm.BuyProduct("Lenovo", 50); Assert.AreEqual(50, product.Quantity); }
public void ReturnMostExpensiveProduct() { StoreManager manager = new StoreManager(); Product product = new Product("Test", 20, 10); Product product1 = new Product("Test1", 30, 20); manager.AddProduct(product); manager.AddProduct(product1); var topProduct = manager.GetTheMostExpensiveProduct(); Assert.AreSame(product1, topProduct); }
public void BuyProductShouldReturnCorrectProduct() { StoreManager sm = new StoreManager(); Product product = new Product("Lenovo", 100, 1500m); Product product2 = new Product("Lenovoooooo", 100000, 150000.50m); sm.AddProduct(product); sm.AddProduct(product2); sm.BuyProduct("Lenovo", 50); Assert.AreEqual("Lenovo", product.Name); }
public void GetTMEProductShouldReturnCorrectProduct() { StoreManager sm = new StoreManager(); Product product = new Product("Lenovo", 100, 1m); Product expected = new Product("Lenovoooooo", 100000, 100m); sm.AddProduct(product); sm.AddProduct(expected); Product actual = sm.GetTheMostExpensiveProduct(); Assert.AreEqual(expected, actual); }
public void TestLastMethod() { var product = new Product("Pesho", 5, 15.5m); var product1 = new Product("Gosho", 5, 5.5m); var store = new StoreManager(); store.AddProduct(product); store.AddProduct(product1); var producto = store.Products.OrderByDescending(p => p.Price).First(); Assert.AreEqual(producto, store.GetTheMostExpensiveProduct()); }
public void Get_Most_Expensive_Product_Should_Return_The_Correct_Product() { var storeManager = new StoreManager(); storeManager.AddProduct(new Product("Pizza", 10, 0.1m)); storeManager.AddProduct(new Product("Salami", 101, 0.5m)); storeManager.AddProduct(new Product("Ham", 120, 1m)); storeManager.AddProduct(new Product("Coke", 104, 3m)); var product = storeManager.GetTheMostExpensiveProduct(); Assert.That(product.Name, Is.EqualTo("Coke")); Assert.That(product.Quantity, Is.EqualTo(104)); Assert.That(product.Price, Is.EqualTo(3)); }
public void GetTheMostExpensiveProductShouldWork() { StoreManager storeManager = new StoreManager(); Product product = new Product("produkt", 3, 2.50m); Product product2 = new Product("produkt2", 3, 12.50m); Product product3 = new Product("produkt3", 3, 6.50m); storeManager.AddProduct(product); storeManager.AddProduct(product2); storeManager.AddProduct(product3); var mostExpensiveProduct = storeManager.GetTheMostExpensiveProduct(); Assert.AreEqual(product2, mostExpensiveProduct); }
public void AddNullProductShouldThrowException() { StoreManager manager = new StoreManager(); Assert.Throws <ArgumentNullException>(() => manager.AddProduct(null)); }
public void MethodGetTheMostExpensiveProductShouldReturnMostExpensiveProduct() { //Arrange StoreManager storeManager = new StoreManager(); Product product = new Product("Product", 20, 50); Product product2 = new Product("Product2", 20, 100); //Act storeManager.AddProduct(product); storeManager.AddProduct(product2); Product expectedResult = product2; Product actualResult = storeManager.GetTheMostExpensiveProduct(); //Assert Assert.AreEqual(expectedResult, actualResult); }
public ActionResult AddProduct(EditProduct product) { var newproduct = _manage.AddProduct(_manage.ToProduct(product)); _manage.SaveProductImage(product, newproduct.ProductId); return(RedirectToAction("Details", "Store", new { id = newproduct.ProductId })); }
public void AddCorrectProductShouldWork() { StoreManager storeManager = new StoreManager(); Product product = new Product("produkt", 2, 2.50m); storeManager.AddProduct(product); Assert.Contains(product, (System.Collections.ICollection)storeManager.Products); }
public void AddProductShgouldThrowNullExceptionWhenAddingNegativeQuantity() { StoreManager sm = new StoreManager(); Product product = new Product("Lenovo", -100, 1500.50m); Assert.Throws <ArgumentException>(() => sm.AddProduct(product)); }
public void Add_Product_Should_Add_Product_Correctly() { var storeManager = new StoreManager(); storeManager.AddProduct(new Product("Pizza", 10, 0.1m)); Assert.That(storeManager.Count, Is.EqualTo(1)); }
public void BuyingShouldCalculateProperly() { StoreManager manager = new StoreManager(); Product product = new Product("Test", 20, 10); Product product1 = new Product("Test1", 30, 20); manager.AddProduct(product); manager.AddProduct(product1); manager.BuyProduct("Test", 20); var expectedTotalQuantity = 0; var expectedFinalPrice = 0; Assert.AreEqual(expectedTotalQuantity, product.Quantity); Assert.AreEqual(expectedFinalPrice, product.Quantity * product.Price); }
public void AddBelowZeroQuantityProductShouldThrowException() { StoreManager manager = new StoreManager(); Product product = new Product("Test", -20, 10); Assert.Throws <ArgumentException>(() => manager.AddProduct(product)); }
public void AddProductShouldThrownExceptionWhenTryToAddNullProduct() { Assert.Throws <ArgumentNullException>(() => { _storeManager.AddProduct(null); }); }
public void AddNullProductWithNegativeQtyShouldThrowException() { StoreManager storeManager = new StoreManager(); Assert.Throws <ArgumentException>(() => { storeManager.AddProduct(new Product("produkt", -20, 2.50m)); }, "Product count can't be below or equal to zero."); }
public void ManagerConstructorWorksCorrectly() { StoreManager sm = new StoreManager(); Product product = new Product("Lenovo", 100, 1500.50m); sm.AddProduct(product); Assert.AreEqual(1, sm.Count); }
public void AddCorrectProductShouldAddProduct() { StoreManager storeManager = new StoreManager(); Product product = new Product("produkt", 2, 2.50m); storeManager.AddProduct(product); Assert.AreEqual(storeManager.Count, 1); }
public void TestAsReadOnly() { var product = new Product("Pesho", 5, 5.5m); var store = new StoreManager(); store.AddProduct(product); Assert.AreEqual(1, store.Products.Count); }
public void StoreManagerBuyProductCorrect() { Product productToBuy = new Product("Z", 5, 1); StoreManager manager = new StoreManager(); manager.AddProduct(productToBuy); manager.BuyProduct(productToBuy.Name, 1); Assert.AreEqual(4, productToBuy.Quantity); }
public void TestConstructor() { var product = new Product("Pesho", 5, 5.5m); var store = new StoreManager(); store.AddProduct(product); Assert.AreEqual(1, store.Count); }
public void TestAddNullException() { var store = new StoreManager(); Assert.Throws <ArgumentNullException>(() => { store.AddProduct(null); }); }
public void TestAddNegativeQuantityException() { var product = new Product("Pesho", -5, 5.5m); var store = new StoreManager(); Assert.Throws <ArgumentException>(() => { store.AddProduct(product); }); }
public void MethodAddProductShouldThrowExceptionIfProductQuantityIsZeroOrBelow(int quantity) { //Arrange StoreManager storeManager = new StoreManager(); Product product = new Product("Product", quantity, 50); //Act - Assert Assert.Throws <ArgumentException>(() => storeManager.AddProduct(product)); }