public void BuyProductShouldThrownExceptionWhenNotExistProduct(string name)
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         _storeManager.BuyProduct(name, 1);
     });
 }
Exemplo n.º 2
0
        public void BuyingMoreThanExistingProductsShouldThrowException()
        {
            StoreManager manager = new StoreManager();
            Product      product = new Product("Test", 20, 10);

            manager.AddProduct(product);
            manager.BuyProduct("Test", 20);

            Assert.Throws <ArgumentException>(()
                                              => manager.BuyProduct("Test", 20));
        }
        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.º 4
0
        public void BuyNullProductShouldThrowException()
        {
            StoreManager storeManager = new StoreManager();

            Assert.Throws <ArgumentNullException>(() =>
            {
                storeManager.BuyProduct("asd", 1);
            });
        }
        public void Buy_Product_Should_Throw_An_Exception_If_The_Product_Quantity_Is_Bellow_Than_The_Wanted_Quantity()
        {
            var storeManager = new StoreManager();

            storeManager.AddProduct(new Product("Pizza", 10, 0.1m));

            Assert.Throws <ArgumentException>(
                () => storeManager.BuyProduct("Pizza", 46),
                "The product qty is not bellow than the wanted quantity.");
        }
        public void Buy_Product_Should_Return_Correct_Product_Price()
        {
            var storeManager = new StoreManager();

            storeManager.AddProduct(new Product("Pizza", 10, 0.1m));

            var price = storeManager.BuyProduct("Pizza", 5);

            Assert.That(price, Is.EqualTo(0.5));
        }
        public void Buy_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.BuyProduct("Salamka", 65),
                "The product is not null.");
        }
Exemplo n.º 8
0
        public void BuyingNullProductShouldThrowException()
        {
            StoreManager manager = new StoreManager();
            Product      product = new Product("Test", 20, 10);

            manager.AddProduct(product);

            Assert.Throws <ArgumentNullException>(()
                                                  => manager.BuyProduct(null, 20));
        }
Exemplo n.º 9
0
        public void BuyProductShouldSubtractQuantity()
        {
            StoreManager storeManager = new StoreManager();
            Product      product      = new Product("produkt", 3, 2.50m);

            storeManager.AddProduct(product);

            storeManager.BuyProduct("produkt", 1);
            Assert.AreEqual(product.Quantity, 2);
        }
Exemplo n.º 10
0
        public void BuyProductWithoutEnoughQtyShouldThrowException()
        {
            StoreManager storeManager = new StoreManager();
            Product      product      = new Product("produkt", 2, 2.50m);

            storeManager.AddProduct(product);
            Assert.Throws <ArgumentException>(() =>
            {
                storeManager.BuyProduct("produkt", 3);
            }, "There is not enough quantity of this product.");
        }
Exemplo n.º 11
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.º 12
0
        public void TestBuyProduct()
        {
            var product = new Product("Pesho", 10, 2m);
            var store   = new StoreManager();

            store.AddProduct(product);

            store.BuyProduct("Pesho", 2);

            Assert.AreEqual(8, product.Quantity);
        }
Exemplo n.º 13
0
        public void BuyProductShouldWork()
        {
            StoreManager storeManager = new StoreManager();
            Product      product      = new Product("produkt", 3, 2.50m);

            storeManager.AddProduct(product);

            storeManager.BuyProduct("produkt", 1);
            decimal finalPrice = product.Price * 1;

            Assert.AreEqual(product.Price * 1, finalPrice);
        }
Exemplo n.º 14
0
        public void TestBuyProductQuantityException()
        {
            var product = new Product("Pesho", 5, 5.5m);
            var store   = new StoreManager();

            store.AddProduct(product);

            Assert.Throws <ArgumentException>(() =>
            {
                store.BuyProduct("Pesho", 30);
            });
        }
Exemplo n.º 15
0
        public void MethodBuyProductShouldThrowExceptionIfDesiredQuantityIsMoreThanActualQuantity()
        {
            //Arrange
            StoreManager storeManager = new StoreManager();
            Product      product      = new Product("Product", 20, 50);

            //Act
            storeManager.AddProduct(product);

            //Assert
            Assert.Throws <ArgumentException>(()
                                              => storeManager.BuyProduct("Product", 30));
        }
Exemplo n.º 16
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.º 17
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.º 18
0
        public void MethodBuyProductShouldThrowExceptionIfProductWithGivenNameIsNull()
        {
            //Arrange
            StoreManager storeManager = new StoreManager();
            Product      product      = new Product("Product", 20, 50);

            //Act
            storeManager.AddProduct(product);

            //Assert
            Assert.Throws <ArgumentNullException>(()
                                                  => storeManager.BuyProduct("Product2", 20));
        }
Exemplo n.º 19
0
        public void MethodBuyProductShouldCalculateAndReturnCorrectFinalPrice()
        {
            //Arrange
            StoreManager storeManager = new StoreManager();
            Product      product      = new Product("Product", 20, 50);

            //Act
            storeManager.AddProduct(product);
            decimal expectedResult = 500;
            decimal actualResult   = storeManager.BuyProduct("Product", 10);

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
Exemplo n.º 20
0
        public void MethodBuyProductShouldDecreaseProductQuantityIfCorrectDataIsGiven()
        {
            //Arrange
            StoreManager storeManager = new StoreManager();
            Product      product      = new Product("Product", 20, 50);

            //Act
            storeManager.AddProduct(product);
            storeManager.BuyProduct("Product", 10);
            int expectedResult = 10;
            int actualResult   = product.Quantity;

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void BuyProductShouldReduceCurrentQuantityWithGivenQuantity()
        {
            string  name     = "Butter";
            int     quantity = 10;
            decimal price    = 5m;

            Product product = new Product(name, quantity, price);

            StoreManager manager = new StoreManager();

            manager.AddProduct(product);
            manager.BuyProduct(product.Name, 6);

            Assert.That(product.Quantity == 4);
        }
        public void BuyProductShouldReturnFinalPrice()
        {
            string  name          = "Butter";
            int     quantity      = 10;
            decimal price         = 100m;
            decimal expectedPrice = price * 6;

            Product product = new Product(name, quantity, price);

            StoreManager manager = new StoreManager();

            manager.AddProduct(product);
            var actualPrice = manager.BuyProduct(product.Name, 6);

            Assert.That(actualPrice == expectedPrice);
        }
Exemplo n.º 23
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);
        }
        public void BuyProductShouldThrowExceptionWhenProductIsNull()
        {
            string  name     = "Butter";
            int     quantity = 10;
            decimal price    = 5m;

            Product product = new Product(name, quantity, price);

            StoreManager manager = new StoreManager();

            manager.AddProduct(product);

            Assert.Throws <ArgumentNullException>(() =>
            {
                manager.BuyProduct("Washmachine", 5);
            });
        }
        public void BuyProductShouldThrowExceptionWhenQuantityIsMoreThanCurrentQuantity()
        {
            string  name     = "Butter";
            int     quantity = 10;
            decimal price    = 5m;

            Product product = new Product(name, quantity, price);

            StoreManager manager = new StoreManager();

            manager.AddProduct(product);

            Assert.Throws <ArgumentException>(() =>
            {
                manager.BuyProduct(product.Name, 11);
            });
        }
 public void BuyProductShouldThrowExceptionWhenProductIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => storeManager.BuyProduct("a", 3));
 }
Exemplo n.º 27
0
 public void ThrowArgumentNullExceptionIfProductToBuyIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => storeManager.BuyProduct("Nik", 10));
 }
        public void StoreManagerBuyProductNull()
        {
            Product productTest = new Product("nqma go", 10, 20);

            Assert.Throws <ArgumentNullException>(() => storeManager.BuyProduct(productTest.Name, 1));
        }