public static StopCalculationResult Build(StarshipResult starship, double distanceInMegaLights)
        {
            var result = new StopCalculationResult()
            {
                StarshipName = starship.Name
            };

            double starshipMegaLights;

            double.TryParse(starship.MGLT, out starshipMegaLights);

            if (starshipMegaLights == 0 || starship.Consumables == "unknown")
            {
                result.TotalStops = 0;
            }
            else
            {
                var hours       = distanceInMegaLights / starshipMegaLights;
                var consumables = starship.Consumables.ToHours();
                var stops       = consumables == 0 ? consumables : hours / consumables;
                result.TotalStops = Math.Floor(stops);
            }

            return(result);
        }
        public void Service_Should_Return_Expected_Value()
        {
            // Arrange
            var distanceInMegLights           = 1000000;
            var externalStarshipService       = Substitute.For <ExternalStarshipService>(Substitute.For <IConfiguration>(), Substitute.For <ILogger <ExternalStarshipService> >());
            var externalStarshipServiceResult = new List <StarshipResult>()
            {
                new StarshipResult()
                {
                    Name        = "Millennium Falcon",
                    MGLT        = "75",
                    Consumables = "2 months"
                }
            };

            externalStarshipService.GetAll().Returns(externalStarshipServiceResult);
            var expectedStarshipResult = new StopCalculationResult()
            {
                StarshipName = "Millennium Falcon",
                TotalStops   = 9
            };
            var service = new StopCalculationService(Substitute.For <ILogger <StopCalculationService> >(), externalStarshipService);

            // Act
            var result = service.GetStopCalculationFromStarships(distanceInMegLights);

            // Assert
            Assert.NotNull(result.First());
            Assert.Equal(expectedStarshipResult.StarshipName, result.First().StarshipName);
            Assert.Equal(expectedStarshipResult.TotalStops, result.First().TotalStops);
        }