Esempio n. 1
0
        public void TotalPrice_ShouldReturnTotalPriceOfAllTheProductsInTheProductsList_WhenProvidedValidInput()
        {
            // Arrange
            var productMock = new Mock <IProduct>();

            productMock.SetupGet(p => p.Price).Returns(20m);
            var productTwoMock = new Mock <IProduct>();

            productTwoMock.SetupGet(p => p.Price).Returns(10m);
            var shoppingCart = new ShoppingCartExtended();

            // Act
            shoppingCart.AddProduct(productMock.Object);
            shoppingCart.AddProduct(productTwoMock.Object);
            var result = shoppingCart.TotalPrice();

            // Assert
            Assert.AreEqual(30, result);
        }
Esempio n. 2
0
        public void AddProduct_ShouldAddTheProvidedProductToTheProductsList_WhenProvidedValidInput()
        {
            // Arrange
            var productMock  = new Mock <IProduct>();
            var shoppingCart = new ShoppingCartExtended();

            // Act
            shoppingCart.AddProduct(productMock.Object);

            // Assert
            CollectionAssert.Contains(shoppingCart.ProductsExposer, productMock.Object);
        }
Esempio n. 3
0
        public void ContainsProduct_ShouldReturnTrueIfThePassedProductIsInTheProductsList_WhenProvidedValidInput()
        {
            // Arrange
            var productMock  = new Mock <IProduct>();
            var shoppingCart = new ShoppingCartExtended();

            // Act
            shoppingCart.AddProduct(productMock.Object);
            bool result = shoppingCart.ContainsProduct(productMock.Object);

            // Assert
            Assert.AreEqual(true, result);
        }
Esempio n. 4
0
        public void RemoveProduct_ShouldRemoveProductFromTheProductsList_WhenProvidedValidInput()
        {
            // Arrange
            var productMock  = new Mock <IProduct>();
            var shoppingCart = new ShoppingCartExtended();

            // Act
            shoppingCart.AddProduct(productMock.Object);
            shoppingCart.RemoveProduct(productMock.Object);

            // Assert
            CollectionAssert.DoesNotContain(shoppingCart.ProductsExposer, productMock.Object);
        }