Ejemplo n.º 1
0
        public void GetTotalCostByDifferentBandsTest()
        {
            var customerId = Guid.NewGuid();

            _moqAccountDetails.Setup(x => x.NumberOfTextMessagesSentInMonth(customerId, 1, 1)).Returns(700);
            _moqAccountDetails.Setup(x => x.GetAccountPriceBands(customerId)).Returns(new List <PriceBand>
            {
                new PriceBand {
                    QtyFrom = 1, QtyTo = 200, PricePerTextMessage = 0.10m
                },
                new PriceBand {
                    QtyFrom = 201, QtyTo = 500, PricePerTextMessage = 0.08m
                },
                new PriceBand {
                    QtyFrom = 501, QtyTo = 1000, PricePerTextMessage = 0.06m
                },
                new PriceBand {
                    QtyFrom = 1001, PricePerTextMessage = 0.03m
                }
            });

            var costCalculator = new TotalCostCalculator(_moqAccountDetails.Object);
            var totalCost      = costCalculator.CalculateCost(customerId, 1, 1);

            Assert.Equal(56.00m, totalCost);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var calculator = new TotalCostCalculator(100);
            var totalCost  = calculator.CalculateTotalCost(price => price * 0.23m, ConsoleNotification);

            Console.WriteLine($"Total cost for $50 after tax for Poland is: ${totalCost}");
        }
        public TotalCostCalculatorTests()
        {
            _accountDetails = A.Fake <IAccountDetails>();

            A.CallTo(() => _accountDetails.GetAccountPriceBands(_customerAccount))
            .Returns(GetAccountPriceBands());

            _calculator = new TotalCostCalculator(_accountDetails);
        }
Ejemplo n.º 4
0
 public DeliveryServiceModel GetOrderCost(DeliveryServiceModel deliveryServiceModel)
 {
     deliveryServiceModel.TotalCost = TotalCostCalculator.CalculateTotalCost(deliveryServiceModel);
     return(this._adapter.Save(deliveryServiceModel));
 }