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); }
public TransportManager() { var truck1Id = SequentialIdGenerator.GenerateIdFor(SequentialIdGenerator.Entity.Truck); var truck1 = new Truck(truck1Id); var truck2Id = SequentialIdGenerator.GenerateIdFor(SequentialIdGenerator.Entity.Truck); var truck2 = new Truck(truck2Id); var ship1Id = SequentialIdGenerator.GenerateIdFor(SequentialIdGenerator.Entity.Ship); var ship1 = new Ship(ship1Id); _availableTransport = new List <ITransport> { truck1, truck2, ship1 }; }