public void RequestPath_SingleThread_NoExceptions() { var multithreadedPathfinder = PathfinderSetup.Create(1); multithreadedPathfinder.Start(); var pathRequest = PathRequest.Create(multithreadedPathfinder, null, null); pathRequest.WaitHandle.WaitOne(1000); Assert.AreEqual(PathRequestStatus.Solved, pathRequest.Status); }
public void RequestPath_SingleThread_NoExceptions() { var manager = new PathfindaxManager(Substitute.For <IUpdatableSynchronizationContext>()); var multithreadedPathfinder = PathfinderSetup.Create(manager, 1); multithreadedPathfinder.Start(); var pathRequest = PathRequest.Create(multithreadedPathfinder, -1, -1); pathRequest.WaitHandle.WaitOne(1000); Assert.AreEqual(PathRequestStatus.Solved, pathRequest.Status); }
public void Integration_StatusFlowToNoPathFound() { var pathfinder = PathfinderSetup.Create(1, false); var request = new PathRequest <IPath>(Substitute.For <IDefinitionNode>(), Substitute.For <IDefinitionNode>()); Assert.AreEqual(PathRequestStatus.Created, request.Status); request.StartSolvePath(pathfinder); Assert.AreEqual(PathRequestStatus.Solving, request.Status); pathfinder.Start(); request.WaitHandle.WaitOne(1000); Assert.AreEqual(PathRequestStatus.NoPathFound, request.Status); }
public void Integration_StatusFlowToNoPathFound() { var manager = new PathfindaxManager(Substitute.For <IUpdatableSynchronizationContext>()); var pathfinder = PathfinderSetup.Create(manager, 1, false); var request = PathRequest.Create <IPath>(-1, -1); Assert.AreEqual(PathRequestStatus.Created, request.Status); pathfinder.RequestPath(request); Assert.AreEqual(PathRequestStatus.Solving, request.Status); pathfinder.Start(); request.WaitHandle.WaitOne(1000); Assert.AreEqual(PathRequestStatus.NoPathFound, request.Status); }
public void Integration_AddCallbackAfterPathIsSolved_CallbackIsCalled() { var pathfinder = PathfinderSetup.Create(1); pathfinder.Start(); var request = PathRequest.Create(pathfinder, Substitute.For <IDefinitionNode>(), Substitute.For <IDefinitionNode>()); request.WaitHandle.WaitOne(1000); var done = false; request.AddCallback(x => done = true); Assert.AreEqual(true, done); }
public void Integration_AddCallbackAfterPathIsSolved_CallbackIsCalled() { var manager = new PathfindaxManager(Substitute.For <IUpdatableSynchronizationContext>()); var pathfinder = PathfinderSetup.Create(manager, 1); pathfinder.Start(); var request = PathRequest.Create(pathfinder, -1, -1); request.WaitHandle.WaitOne(1000); var done = false; request.AddCallback(x => done = true); Assert.AreEqual(true, done); }
public void Integration_AddCallbackBeforePathIsSolved_CallbackIsCalled() { var pathfinder = PathfinderSetup.Create(1); pathfinder.Start(); var request = PathRequest.Create <IPath>(Substitute.For <IDefinitionNode>(), Substitute.For <IDefinitionNode>()); var done = false; request.AddCallback(x => done = true); request.StartSolvePath(pathfinder); request.WaitHandle.WaitOne(1000); pathfinder.ProcessPaths(); //This should call the callback if the path is finished. Assert.AreEqual(true, done); }
public void Integration_AddCallbackBeforePathIsSolved_CallbackIsCalled() { var manager = new PathfindaxManager(new UpdatableSynchronizationContext()); var pathfinder = PathfinderSetup.Create(manager, 1); pathfinder.Start(); var request = PathRequest.Create <IPath>(-1, -1); var done = false; request.AddCallback(x => done = true); pathfinder.RequestPath(request); request.WaitHandle.WaitOne(1000); manager.Update(1f); //This should call the callback if the path is finished. Assert.AreEqual(true, done); }
public void RequestPath_MultipleThreads_NoExceptions() { var multithreadedPathfinder = PathfinderSetup.Create(4); multithreadedPathfinder.Start(); var pathRequests = new PathRequest <IPath> [64]; for (var i = 0; i < pathRequests.Length; i++) { pathRequests[i] = PathRequest.Create(multithreadedPathfinder, null, null);; } WaitHandle.WaitAll(pathRequests.Select(x => x.WaitHandle).ToArray(), 2000); foreach (var pathRequest in pathRequests) { Assert.AreEqual(PathRequestStatus.Solved, pathRequest.Status); } }
public void RequestPath_MultipleThreads_NoExceptions() { var manager = new PathfindaxManager(Substitute.For <IUpdatableSynchronizationContext>()); var multithreadedPathfinder = PathfinderSetup.Create(manager, 4); multithreadedPathfinder.Start(); var pathRequests = new PathRequest <IPath> [64]; for (var i = 0; i < pathRequests.Length; i++) { pathRequests[i] = PathRequest.Create(multithreadedPathfinder, -1, -1);; } WaitHandle.WaitAll(pathRequests.Select(x => x.WaitHandle).ToArray(), 2000); foreach (var pathRequest in pathRequests) { Assert.AreEqual(PathRequestStatus.Solved, pathRequest.Status); } }