public void CorrectlyAddVehicle()
        {
            string plate = "912389SADAB1JSK";

            int vehiclesInList  = vvm.VehiclesCollection.Count;
            int vehiclesInModel = new List <Vehicle>(Vehicles.All()).Count;

            vvm.AddVehicle(true);
            Assert.AreNotEqual(null, vvm.AddVehicleWindow);
            vvm.HandleAddVehicle(plate, 1);

            Assert.AreEqual(vehiclesInList + 1, vvm.VehiclesCollection.Count);
            Assert.AreEqual(vehiclesInModel + 1, new List <Vehicle>(Vehicles.All()).Count);

            List <Vehicle> vehiclesList = new List <Vehicle>(Vehicles.All());
            Vehicle        vehicle      = vehiclesList.FindLast(i => i.Plate == plate);

            if (vehicle == null)
            {
                Assert.Fail();
            }

            vvm.SelectedVehicle = vehicle;
            Vehicles.Delete(vehicle.Id);
        }
Beispiel #2
0
        protected override void PrepareVehiclesWithStructures(SeaPortZoneClusterConsumption[] structures)
        {
            int desiredAmountOfShips = structures.Count() * AmountOfShipsPerHarbour;

            var candidates = _candidatesCache.GetValue();

            if (candidates == null)
            {
                return;
            }

            while (NewShipCanBeInserted &&
                   Vehicles.Count() < desiredAmountOfShips &&
                   Vehicles.All(x => x.IsReadyAndMoving))
            {
                var candidate = GetZoneInfosFunc()
                                .Where(IsSuitableForShip)
                                .OrderBy(x => Random.Next())
                                .FirstOrDefault();

                if (candidate != null)
                {
                    AddVehicle(new Ship(GetZoneInfosFunc, candidate, _shipSpeedInMilliSeconds, _maxDistance));
                    _lastShipInsertion = DateTime.Now;
                }
                else
                {
                    return;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Determines whether all orders have been fulfilled successfully
        /// </summary>
        /// <returns></returns>
        public bool IsDone()
        {
            if (OpenOrders.Count == 0 && Vehicles.All(v => v.State == VehicleState.Idle))
            {
                return(true);
            }

            if (OpenOrders.Count > 0)
            {
                if (Vehicles.All(v => v.State == VehicleState.Idle && v.FindOptimalOrders()?.Count == 0))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #4
0
 private RaceStatusType CheckRaceStatus()
 {
     var isFinished = Vehicles.All(vehicle => vehicle.Status != VehicleStatus.Running && vehicle.Status != VehicleStatus.LightMalfunction);
     return isFinished ? RaceStatusType.Finished : Status;
 }
Beispiel #5
0
 public void ReturnFalseIfTheSequenceContainsAnyThatDoNotSatisfyThePredicate()
 {
     Assert.False(Vehicles.All(v => v.FuelEconomy.Combined > 20));
 }
Beispiel #6
0
 public void ReturnTrueIfTheSequenceContainsOnlyElementsThatSatisfyThePredicate()
 {
     Assert.True(Vehicles.All(v => v.FuelEconomy.Combined > 5));
 }