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);
        }
Exemplo n.º 2
0
        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.");
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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));
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        public void AddNullProductShouldThrowException()
        {
            StoreManager manager = new StoreManager();

            Assert.Throws <ArgumentNullException>(()
                                                  => manager.AddProduct(null));
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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 }));
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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));
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        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);
     });
 }
Exemplo n.º 22
0
        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.");
        }
Exemplo n.º 23
0
        public void ManagerConstructorWorksCorrectly()
        {
            StoreManager sm      = new StoreManager();
            Product      product = new Product("Lenovo", 100, 1500.50m);

            sm.AddProduct(product);

            Assert.AreEqual(1, sm.Count);
        }
Exemplo n.º 24
0
        public void AddCorrectProductShouldAddProduct()
        {
            StoreManager storeManager = new StoreManager();
            Product      product      = new Product("produkt", 2, 2.50m);

            storeManager.AddProduct(product);

            Assert.AreEqual(storeManager.Count, 1);
        }
Exemplo n.º 25
0
        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);
        }
Exemplo n.º 27
0
        public void TestConstructor()
        {
            var product = new Product("Pesho", 5, 5.5m);
            var store   = new StoreManager();

            store.AddProduct(product);

            Assert.AreEqual(1, store.Count);
        }
Exemplo n.º 28
0
        public void TestAddNullException()
        {
            var store = new StoreManager();

            Assert.Throws <ArgumentNullException>(() =>
            {
                store.AddProduct(null);
            });
        }
Exemplo n.º 29
0
        public void TestAddNegativeQuantityException()
        {
            var product = new Product("Pesho", -5, 5.5m);
            var store   = new StoreManager();

            Assert.Throws <ArgumentException>(() =>
            {
                store.AddProduct(product);
            });
        }
Exemplo n.º 30
0
        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));
        }