Exemplo n.º 1
0
        public void TotalPrice_ShouldReturnZeroWhenThereAreNoProductsInTheProductsList_WhenProvidedValidInput()
        {
            // Arrange
            var shoppingCart = new ShoppingCartExtended();

            // Act
            var result = shoppingCart.TotalPrice();

            // Assert
            //Assert.AreEqual(0, result);
            Assert.That(result, Is.Zero);
        }
Exemplo n.º 2
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);
        }