Example #1
0
        public bool IsNear(Path.Waypoint position)
        {
            if (position is null)
            {
                throw new ArgumentNullException(nameof(position));
            }

            if (LastWaypoint is null)
            {
                throw new InvalidOperationException($"Invalid call to {nameof(IsNear)}, no path is available.");
            }

            return(_path.Count == 1);
        }
Example #2
0
        public void UpdateAsync_Success_WhenNoPathIsAvailableOrComponentIsStuck(Path.Waypoint waypoint, bool isStuck)
        {
            Task expectedTask = new(() => { });

            _pathManagerMock.SetupGet(manager => manager.LastWaypoint).Returns(waypoint);
            _pathManagerMock.Setup(manager => manager.RequestNewPath()).Returns(expectedTask);
            _stuckManagerMock.SetupGet(manager => manager.IsStuck).Returns(isStuck);

            var resultTask = _movementHandler.UpdateAsync();

            Assert.Same(expectedTask, resultTask);

            _pathManagerMock.Verify(manager => manager.LastWaypoint, Times.Once);
            _pathManagerMock.Verify(manager => manager.RequestNewPath(), Times.Once);
            _stuckManagerMock.Verify(manager => manager.IsStuck, isStuck ? Times.Exactly(2) : Times.Once());

            if (isStuck)
            {
                _stuckManagerMock.Verify(manager => manager.Reset(), Times.Once);
            }
        }
Example #3
0
 public void SetPosition(Path.Waypoint position)
 {
     // nothing to do... we are not in the real world...
 }