예제 #1
0
        public void TotalCost_WithDiscount()
        {
            //Arrange
            _sut = new BusinessCore.Areas.ShoppingBasket.Models.ShoppingBasket
            {
                Items = new List <IItem>
                {
                    new Item {
                        PricePerItem = 10, Qty = 5, Sku = "A"
                    },
                    new Item {
                        PricePerItem = 5, Qty = 2, Sku = "B"
                    }
                },
                Discounts = new List <IDiscount>
                {
                    new Discount {
                        PricePerOffer = -5, Qty = 2, Sku = "A"
                    },
                    new Discount {
                        PricePerOffer = -2.5, Qty = 1, Sku = "B"
                    }
                }
            };

            //Act
            var result = _sut.TotalCost();

            //Assert
            result.Should().Be(47.5);
        }
예제 #2
0
        public void TotalCost_NoDiscount(double itemOnePrice, double itemTwoPrice, int itemOneQty, int itemTwoQty, double expectedResult)
        {
            //Arrange
            _sut = new BusinessCore.Areas.ShoppingBasket.Models.ShoppingBasket
            {
                Items = new List <IItem>
                {
                    new Item {
                        PricePerItem = itemOnePrice, Qty = itemOneQty
                    },
                    new Item {
                        PricePerItem = itemTwoPrice, Qty = itemTwoQty
                    }
                }
            };

            //Act
            var result = _sut.TotalCost();

            //Assert
            result.Should().Be(expectedResult);
        }