コード例 #1
0
        public void SpaceTrip_GetResupplyStopsQuantityMaxDecimalDistance_Success()
        {
            // Arrange
            var           distance    = decimal.MaxValue.ToString();
            const decimal MGLT        = 10.00000000001M;
            const string  CONSUMABLES = "10 years";
            var           spaceTrip   = new SpaceTrip(distance);

            // Act
            var resupplyStops = spaceTrip.GetResupplyStopsQuantity(MGLT, CONSUMABLES);

            // Assert
            Assert.True(resupplyStops > 0);
        }
コード例 #2
0
        public void SpaceTrip_GetResupplyStopsQuantity_MustReturn0()
        {
            // Arrange
            const string  DISTANCE        = "100";
            const decimal MGLT            = 10.00000000001M;
            const string  CONSUMABLES     = "10 hours";
            const int     EXPECTED_RESULT = 0;
            var           spaceTrip       = new SpaceTrip(DISTANCE);

            // Act
            var resupplyStops = spaceTrip.GetResupplyStopsQuantity(MGLT, CONSUMABLES);

            // Assert
            Assert.Equal(EXPECTED_RESULT, resupplyStops);
        }
コード例 #3
0
        private static string ComputeStops(StarShip starShip, SpaceTrip spaceTrip)
        {
            if (!decimal.TryParse(starShip.Mglt, out decimal mglt))
            {
                return("Not available (MGLT = 'unknown')");
            }
            var consumables = starShip.Consumables.ToLower();

            if (consumables == "unknown")
            {
                return("Not available (consumables = 'unknown')");
            }

            var result = spaceTrip.GetResupplyStopsQuantity(mglt, consumables);

            return(FormatResult(result));
        }