예제 #1
0
        public void Run(string destinationString, int expectedTime)
        {
            var cargoes = new List <Cargo>();

            var destinations = destinationString.Split(",", StringSplitOptions.RemoveEmptyEntries);

            foreach (var destinationName in destinations)
            {
                var destination = Destination.FromString(destinationName);

                var cargoId = SequentialIdGenerator.GenerateIdFor(SequentialIdGenerator.Entity.Cargo);

                var cargo = new Cargo(cargoId, destination);

                cargoes.Add(cargo);

                _deliveryManager.PlanDelivery(cargo);
            }

            int time = 0;

            while (!cargoes.All(cargo => cargo.IsDelivered))
            {
                _deliveryManager.Tick(time);

                time++;
            }

            Assert.Equal(expectedTime, time - 1);
        }