コード例 #1
0
        public void TestNightAndPeakSurcharge()
        {
            DateTime dateTime = new DateTime(2020, 3, 3, 19, 59, 0);
            decimal  answer   = FareManager.CalculateFare(5, 1M, dateTime, new NewYorkRates());

            Assert.AreEqual(8.50M, answer);
        }
コード例 #2
0
        public void TestMilesFraction()
        {
            DateTime dateTime = new DateTime(2020, 3, 3, 19, 0, 0);
            decimal  answer   = FareManager.CalculateFare(1, 1.6M, dateTime, new NewYorkRates());

            Assert.AreEqual(7.65M, answer);
        }
コード例 #3
0
        public void TestNoHourSurcharges()
        {
            DateTime dateTime = new DateTime(2020, 3, 7, 19, 0, 0);
            decimal  answer   = FareManager.CalculateFare(1, 1M, dateTime, new NewYorkRates());

            Assert.AreEqual(5.60M, answer);
        }
コード例 #4
0
 public ActionResult <decimal> GetFare([FromBody] Fare fare)
 {
     if (fare == null)
     {
         return(BadRequest());
     }
     try
     {
         return(FareManager.CalculateFare(fare.MinutesAbove6, fare.MilesBelow6, fare.StartTime, new NewYorkRates()));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(new StatusCodeResult((int)HttpStatusCode.InternalServerError));
     }
 }