Esempio n. 1
0
        public void TestNormalDistributedSpawns()
        {
            //Arrange

            //Act
            var droneLogic = new DroneLogic(50);

            //Assert
            Assert.IsNotEmpty(droneLogic.SpawnTimes, "Drone objects were not generated");
            Assert.AreEqual(50, droneLogic.SpawnTimes.Count, "The correct number of times was not generated");
        }
Esempio n. 2
0
        public void TestRemoveDrones()
        {
            //Arrange
            const int numToKeep  = 9;
            var       unitOfWork = new UnitOfWork(new DtsContext());

            //Act
            DroneLogic.RemoveDrones(numToKeep);

            //Assert
            Assert.AreEqual(numToKeep - 1, unitOfWork.Drones.GetAll().Count(), "The number of drones should be equal to 40");
        }
Esempio n. 3
0
        public void TestGenerateNewDrones()
        {
            //Arrange
            const int numDrones  = 10;
            const int droneCount = 0;

            //Act
            var droneList = DroneLogic.GenerateNewDrones(numDrones, droneCount).ToList();

            //Assert
            Assert.IsNotEmpty(droneList, "The list of drones is empty and was not generated");
            Assert.AreEqual(droneList.Count, numDrones, "The number of drones generated was less than 10");
            Assert.True(droneList.All(x => x.Scale.Id >= 1), "One of the scales generated an id less than 1");
            Assert.True(droneList.All(x => x.Scale.Id <= 7), "One of the scales has an incorrect id greater than 7");
        }
Esempio n. 4
0
        public void TestCheckSpawnTimes()
        {
            //Arrange
            var droneLogic = new DroneLogic(50);

            droneLogic.SpawnTimes.Clear();
            droneLogic.SpawnTimes.Add(DateTime.MinValue.AddSeconds(1));

            //Act
            var correctTime = droneLogic.CheckTimeToSpawn();

            //Assert
            Assert.True(correctTime, "It is not the current time yet");
            Assert.IsNotEmpty(droneLogic.SpawnTimes, "There are values in the spawn times");
            Assert.AreEqual(droneLogic.SpawnTimes.Count, 1, "The spawn times were not cleared or they were not added");
        }
Esempio n. 5
0
        //Loops through each drone to update their position and remove them from the world if necessary
        private async Task NavigateDrones()
        {
            var toRemove = new List <int>();

            foreach (var drone in Drones.ToList())
            {
                toRemove.Add(await NavigateToNexPoint(drone));
            }
            foreach (var key in toRemove.Where(x => x != 0))
            {
                var drone = Drones.ContainsKey(key) ? Drones[key] : null;
                SceneSystem.SceneInstance.RootScene.Entities.Remove(drone);
                Drones.Remove(key);
                DistanceTravelled.Remove(key);
                _routes.Remove(key);
                _waypointIndexes.Remove(key);
                Speeds.Remove(key);
                DroneLogic.SetDroneNotLive(key);
            }
        }
Esempio n. 6
0
        public void TestAddDrone()
        {
            //Arrange
            var unitOfWork      = new UnitOfWork(new DtsContext());
            var comparisionList = unitOfWork.Drones.GetAll().ToList();

            unitOfWork.Dispose();
            var droneLogic = new DroneLogic(50);

            droneLogic.SpawnTimes.Clear();
            droneLogic.SpawnTimes.Add(DateTime.MinValue.AddSeconds(1));

            //Act
            var result = droneLogic.AddDrone();

            //Assert
            Assert.IsNotEmpty(comparisionList.Where(x => x.Id == result.Key.Id), "The Id generated does not exist");
            Assert.IsNotNull(result.Key.CurrentPoint, "The current point was not generated");
            Assert.True(result.Value, "The spawn time is incorrect");

            ResetValues(result.Key.Id);
        }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        if (null != state)
        {
            for (int j = 0; j < state["units"].Count; j++)
            {
                JSONNode unit = state["units"][j];

                //Debug.Log("HDFL");
                //Debug.Log(unit["name"]);

                GameObject unitObj = GameObject.Find(unit["name"]);
                if (unitObj)
                {
                    DroneLogic dLogic = (DroneLogic)unitObj.GetComponent(typeof(DroneLogic));
                    dLogic.setState(unit);
                }
                else
                {
                    Debug.Log("not found");
                }
            }
        }
    }
Esempio n. 8
0
 //Generates new drones
 public override void Start()
 {
     base.Start();
     DroneLogic.UpdateNumberOfDrones(NumberOfDronesToGenerate);
 }