Beispiel #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>());
        }
Beispiel #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)");
            }
        }
Beispiel #3
0
        public void Test_calculate_hours_day()
        {
            var hours = _function.CalculateHours(new Consumable(TimeUnit.Day, 12));

            Assert.Equal(288, hours);
        }