Exemplo n.º 1
0
        public void AddProductWhenNullShouldThrowException()
        {
            webshop = new MyWebshop(basket = new Basket());
            Product p = null;

            Assert.Throws <IncorrectProductException>(() => webshop.Basket.AddProduct(p, 2), "Product can not be null");
        }
Exemplo n.º 2
0
        public void AddProductWithPriceZeroShouldThrowException()
        {
            webshop = new MyWebshop(basket = new Basket());
            Product p = new Product()
            {
            };

            Assert.Throws <IncorrectPriceException>(() => webshop.Basket.AddProduct(p, 2), "Price can not be 0");
        }
Exemplo n.º 3
0
        public void AddingProductWithoutPriceShouldThrowException()
        {
            webshop = new YarnWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 0
            };

            Assert.Throws <WrongPriceException>(() => webshop.Basket.AddProduct(p, 1), "Productpricing is zero");
        }
Exemplo n.º 4
0
        public void AddProductWithNegativeAmountShouldThrowException()
        {
            webshop = new MyWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 20.00m
            };

            Assert.Throws <IncorrectAmountException>(() => webshop.Basket.AddProduct(p, -1), "Amount must be above 0");
        }
Exemplo n.º 5
0
        public void AddProductWithoutPriceShouldThrowException()
        {
            webshop = new MyWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = -0.01M
            };

            Assert.Throws <IncorrectPriceException>(() => webshop.Basket.AddProduct(p, 2), "Price can not be empty");
        }
Exemplo n.º 6
0
        public void AddingProductWithoutValidPriceShouldThrowException(int amount)
        {
            webshop = new YarnWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 300m
            };

            webshop.Basket.AddProduct(p, amount);
            Assert.AreEqual(p.Price * amount, webshop.Basket.TotalCost, "Productpricing is wrong");
        }
Exemplo n.º 7
0
        public void AddingProductWithValidPriceAndFormatShouldBeSuccessful()
        {
            webshop = new YarnWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 300m
            };

            webshop.Basket.AddProduct(p, 3);
            Assert.AreEqual(p.Price * 3, webshop.Basket.TotalCost, "Product should be added");
        }
Exemplo n.º 8
0
        public void RemovingToManyShouldThrowException()
        {
            webshop = new YarnWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 150.00m
            };

            webshop.Basket.AddProduct(p, 2);

            Assert.Throws <WrongProductRemovalException>(() => webshop.Basket.RemoveProduct(p, 4), "Should be removed");
        }
Exemplo n.º 9
0
        public void AddProductShouldSucceedAddToList(int amount)
        {
            webshop = new MyWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 20.00m
            };

            webshop.Basket.AddProduct(p, amount);

            Assert.AreEqual(p.Price * amount, webshop.Basket.TotalCost, "Does not match");
        }
Exemplo n.º 10
0
        public void CheckOutWhenIBillingIsNullIsNullShouldThrowException()
        {
            webshop = new MyWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 10.00m
            };

            webshop.Basket.AddProduct(p, 2);

            Assert.Throws <IncorrectBillingException>(() => webshop.Checkout(null), "Basket should need a billing.");
        }
Exemplo n.º 11
0
        public void NotEnoughCashShouldThrowException()
        {
            webshop = new MyWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 10.00m
            };

            webshop.Basket.AddProduct(p, 2);

            Assert.Throws <NotEnoughCashException>(() => webshop.Checkout(billing = new MockBilling(19.00m)), "You should not have enough cash");
        }
Exemplo n.º 12
0
        public void RemoveZeroProductShouldThrowException()
        {
            webshop = new MyWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 10.00m
            };

            webshop.Basket.AddProduct(p, 2);

            Assert.Throws <IncorrectActionException>(() => webshop.Basket.RemoveProduct(p, 0), "Should not be able to remove zero products");
        }
Exemplo n.º 13
0
        public void RemoveMoreProductsThanInBasketShouldThrowException()
        {
            webshop = new MyWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 10.00m
            };

            webshop.Basket.AddProduct(p, 2);

            Assert.Throws <IncorrectActionException>(() => webshop.Basket.RemoveProduct(p, 3), "Should work");
        }
Exemplo n.º 14
0
        public void CheckoutWithBillingNullShouldThrowException()
        {
            webshop = new YarnWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 295.00m
            };

            webshop.Basket.AddProduct(p, 4);

            Assert.Throws <WrongBillingException>(() => webshop.Checkout(null), "Basket should be billed first");
        }
Exemplo n.º 15
0
        public void RemoveProductShouldSucceed(int amount)
        {
            webshop = new MyWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 10.00m
            };

            webshop.Basket.AddProduct(p, amount);
            webshop.Basket.RemoveProduct(p, amount);

            Assert.That(webshop.Basket.TotalCost, Is.EqualTo(0), "Should be the same");
        }
Exemplo n.º 16
0
        public void TooLittleOnBalanceShouldThrowException()
        {
            webshop = new YarnWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 295.00m
            };

            webshop.Basket.AddProduct(p, 4);
            var newbalance = billing.Balance;

            Assert.Throws <InsufficientFundsException>(() => webshop.Checkout(billing = new MockBilling(600m)), "Money should not be sufficient");
        }
Exemplo n.º 17
0
        public void AllValidCheckoutShouldBeSuccessful()
        {
            webshop = new YarnWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 295.00m
            };

            webshop.Basket.AddProduct(p, 4);
            webshop.Checkout(billing = new MockBilling(1180m));
            var newbalance = billing.Balance;

            Assert.AreEqual(0, newbalance, "Money should cover billing");
        }
        static void Main(string[] args)
        {
            SzamtechBolt szb = new SzamtechBolt();

            //szb.GetArlista();
            ((IUzlet)szb).GetArlista();

            IWebshop ws = szb;

            ws.GetArlista();


            Console.ReadLine();
        }
Exemplo n.º 19
0
        public void EnoughCashShouldSucceed()
        {
            webshop = new MyWebshop(basket = new Basket());
            Product p = new Product()
            {
                Price = 10.00m
            };

            webshop.Basket.AddProduct(p, 2);

            webshop.Checkout(billing = new MockBilling(21.00m));

            var currentBalance = billing.Balance;

            Assert.AreEqual(1.00m, currentBalance, "You should have enough cash");
        }
Exemplo n.º 20
0
 public void CreateMyWebshopWhenBasketIsNullShouldThrowException()
 {
     Assert.Throws <IncorrectBasketException>(() => webshop = new MyWebshop(null), "Webshop should need a basket.");
 }
Exemplo n.º 21
0
 public void CreateMyWebshopWhenBasketIsNullShouldThrowException()
 {
     Assert.Throws <MissingBasketException>(() => webshop = new YarnWebshop(null), "Webshop has no basket yet.");
 }