Exemplo n.º 1
0
        public void GetPath_ManagerNotStarted_ThrowsException()
        {
            using var gate = new AutoResetEvent(false);
            var callback = new PathfindingCallback(gate);
            IPathfindingManager manager = new PathfindingManager();

            try {
                Assert.That(() => {
                    manager.GetPath(_map, ref _map.GetCell(0, 0), ref _map.GetCell(_map.Columns - 1, _map.Rows - 1), Locomotion.Walk, callback, 0);
                }, Throws.InvalidOperationException);
            } finally {
                manager.Stop();
            }
        }
Exemplo n.º 2
0
        public void Stop_AlreadyStarted_ThreadStopped()
        {
            using var gate = new AutoResetEvent(false);
            IPathfindingManager manager = new PathfindingManager();
            int stopCount = 0;

            manager.Started += (_, __) => {
                gate.Set();
            };
            manager.Stopped += (_, __) => {
                stopCount += 1;
                gate.Set();
            };
            manager.Start();
            gate.WaitOne(DELAY_MS);
            manager.Stop();
            gate.WaitOne(DELAY_MS);

            manager.Stop();
            gate.WaitOne(DELAY_MS);

            Assert.That(stopCount, Is.EqualTo(1));
        }
Exemplo n.º 3
0
 public void OnDestroy()
 {
     Instance = null;
     PathfindingManager.Stop();
     Pathfinding.Clean();
 }