예제 #1
0
        public async Task Test_app_full()
        {
            long distance = 1000000;
            long hours    = 13440;

            _download.GetStarships().Returns(TestFactory.CreateMock());

            Starship   starship   = TestFactory.CreateMock().FirstOrDefault();
            Consumable consumable = new Consumable(TimeUnit.Week, 1);

            _function.SeparateConsumable(starship.consumables).Returns(consumable);
            _function.CalculateHours(consumable).Returns(hours);
            _function.CalculateStops(distance, starship.MGLT.ToInt64(), hours).Returns(74);

            App app = new App(_download, _logger, _function);
            await app.Start(distance);

            long expected = 74;

            _logger.Received().Success($"The starship Millennium Falcon needs {expected} stop(s)");

            _logger.Received(2).Message(Arg.Any <string>());
            _logger.Received(1).Success(Arg.Any <string>());
            _logger.Received(0).Error(Arg.Any <string>());
        }
예제 #2
0
        /// <summary>
        /// Calculates the distance for each starship
        /// </summary>
        /// <param name="starships"></param>
        private void CalculateStops(long distance, List <Starship> starships)
        {
            foreach (Starship starship in starships)
            {
                if (starship.MGLT.ToLower().Equals("unknown"))
                {
                    _logger.Error($"Unknown MGLT for {starship.name}");
                    continue;
                }
                Consumable consumable = _function.SeparateConsumable(starship.consumables);

                long hours = _function.CalculateHours(consumable);

                long stops = _function.CalculateStops(distance, starship.MGLT.ToInt64(), hours);

                _logger.Success($"The starship {starship.name} needs {stops} stop(s)");
            }
        }
예제 #3
0
        public void Test_calculate_stops()
        {
            var stops = _function.CalculateStops(1000000, 80, 168);

            Assert.Equal(74, stops);
        }