Ejemplo n.º 1
0
        public void RateCalculator_Calculate_ShouldCalculateRate(decimal baseRate, decimal quoteRate, decimal expected)
        {
            var rateCalculator = new RateCalculator();
            var baseCurrency   = new Currency {
                Rate = baseRate
            };
            var quoteCurrency = new Currency {
                Rate = quoteRate
            };

            var actual = rateCalculator.CalculateRate(baseCurrency, quoteCurrency);

            actual.Should().Be(expected);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> PostShipment(Shipment shipment)
        {
            // validation must be done and return badrequest if not

            if (shipment?.Manifest?.FlightNumber == null)
            {
                return(BadRequest());
            }

            Db.Entry(shipment.Manifest).State = EntityState.Unchanged;

            shipment.Fee = await rateCalculator.CalculateRate(shipment.MailType, shipment.Origin, shipment.Destination, shipment.Weight, shipment.NumberOfItems);

            await Db.Shipments.AddAsync(shipment);

            await Db.SaveChangesAsync();

            return(NoContent());
        }
Ejemplo n.º 3
0
 public async Task <ActionResult <decimal> > Calculate(MailType mailType, string origin, string destination, decimal weight, int numberOfItems)
 {
     return(await rateCalculator.CalculateRate(mailType, origin, destination, weight, numberOfItems));
 }
Ejemplo n.º 4
0
 public Ticket InsertCoins(decimal coinSum)
 {
     return(new Ticket(coinSum, (int)Math.Floor(coinSum / RateCalculator.CalculateRate())));
 }