public void CalculatePrice_ShouldSumAllPricesForAllItems()
        {
            int     quantity      = 1;
            decimal priceForItemA = 1.25m;
            decimal priceForItemB = 4.25m;
            decimal expectedTotal = priceForItemA + priceForItemB;

            var orderList = new OrderList();

            orderList.AddItem(new StockItem("A"), priceForItemA);
            orderList.AddItem(new StockItem("B"), priceForItemB);

            _calculationRuleMock.Setup(i => i.CalculatePrice(quantity, priceForItemA))
            .Returns(priceForItemA)
            .Verifiable();

            _calculationRuleMock.Setup(i => i.CalculatePrice(quantity, priceForItemB))
            .Returns(priceForItemB)
            .Verifiable();

            var totalPrice = _sut.CalculatePrice(orderList);

            Assert.AreEqual(expectedTotal, totalPrice, "Total price should match");
            _calculationRuleMock.VerifyAll();
            _calculationRulesProviderMock.VerifyAll();
        }
        public void CalculatePrice_ShouldCallCalcualtionRuleForEachItem_WhenThereIsMoreThenOneItemInTheOrderList()
        {
            int     quantity           = 1;
            decimal priceForSingleItem = 1.25m;
            var     orderList          = new OrderList();

            orderList.AddItem(new StockItem("A"), priceForSingleItem);
            orderList.AddItem(new StockItem("B"), priceForSingleItem);

            _sut.CalculatePrice(orderList);

            _calculationRuleMock.Verify(i => i.CalculatePrice(quantity, priceForSingleItem), Times.Exactly(2));
            _calculationRulesProviderMock.Verify();
        }
        public void GetOrderItems_ShouldReturnAListWithTwoItems_WhenTwoOrderItemsWhereAdded()
        {
            var stockItemA = new StockItem("A");
            var stockItemB = new StockItem("B");
            var priceA     = 1.25m;
            var priceB     = 4.25m;

            _sut.AddItem(stockItemA, priceA);
            _sut.AddItem(stockItemB, priceB);

            var itemsInTheList = _sut.GetOrderItems();

            Assert.AreEqual(2, itemsInTheList.Count, "Order list should contain 2 items");
            Assert.IsTrue(itemsInTheList.Any(i => i.ItemCode == stockItemA.Code && i.Price == priceA),
                          "List should contain stockitem1 with correct price");
            Assert.IsTrue(itemsInTheList.Any(i => i.ItemCode == stockItemB.Code && i.Price == priceB),
                          "List should contain stockitem2 with correct price");
        }