Beispiel #1
0
        public void ReturnZero_WhenCalledWithNoProductsInTheCarProductsCollection()
        {
            // arrange
            var cart = new FakeShoppingCart();

            // act
            var totalPrice = cart.TotalPrice();

            // assert
            Assert.AreEqual(0, totalPrice);
        }
        public void AddTheProductSuccessfullyToProductsCollection_WhenCalledWithValidProduct()
        {
            // arrange
            var cart        = new FakeShoppingCart();
            var productStub = new Mock <IProduct>();

            // act
            cart.AddProduct(productStub.Object);

            // assert
            Assert.AreSame(productStub.Object, cart.Products.First());
        }
Beispiel #3
0
        public void ReturnTrue_WhenProductIsPresentInTheProductsCollection()
        {
            // arrange
            var cart        = new FakeShoppingCart();
            var productStub = new Mock <IProduct>();

            cart.Products.Add(productStub.Object);

            // act
            bool isContained = cart.ContainsProduct(productStub.Object);

            // assert
            Assert.IsTrue(isContained);
        }
        public void RemoveProductFromProductsCollcetionSuccessfully_WhenCalledWithAValidProduct()
        {
            // arrange
            var cart        = new FakeShoppingCart();
            var productStub = new Mock <IProduct>();

            cart.Products.Add(productStub.Object);

            // act
            cart.RemoveProduct(productStub.Object);

            // asssert
            Assert.AreEqual(0, cart.Products.Count);
        }
Beispiel #5
0
        public void ReturnTotalPriceOfAllProductsInTheProductCollection_WhenCalledWithPresenteProducts()
        {
            // arrange
            var cart        = new FakeShoppingCart();
            var productStub = new Mock <IProduct>();

            decimal price = 22;

            productStub.Setup(x => x.Price).Returns(price);

            cart.Products.Add(productStub.Object);

            // act
            var totalPrice = cart.TotalPrice();

            // assert
            Assert.AreEqual(price, totalPrice);
        }