Initial commit
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
using RobotNet10.GlobalPathPlanner.Differential;
|
||||
using RobotNet10.GlobalPathPlanner.Model;
|
||||
|
||||
namespace RobotNet10.GlobalPathPlanner.UnitTest;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for IPathPlanner interface contract
|
||||
/// </summary>
|
||||
public class IPathPlannerTests
|
||||
{
|
||||
[Fact]
|
||||
public void IPathPlanner_Implementation_ShouldImplementAllMethods()
|
||||
{
|
||||
// Arrange
|
||||
var planner = new DifferentialPlanner() as IPathPlanner;
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(planner);
|
||||
Assert.NotNull(planner.GetType().GetMethod(nameof(IPathPlanner.SetData)));
|
||||
Assert.NotNull(planner.GetType().GetMethod(nameof(IPathPlanner.SetOptions)));
|
||||
Assert.NotNull(planner.GetType().GetMethod(nameof(IPathPlanner.PathPlanning), new[] { typeof(double), typeof(double), typeof(double), typeof(Guid), typeof(CancellationToken?) }));
|
||||
Assert.NotNull(planner.GetType().GetMethod(nameof(IPathPlanner.PathPlanning), new[] { typeof(Guid), typeof(double), typeof(Guid), typeof(CancellationToken?) }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IPathPlanner_SetData_ShouldAcceptNodesAndEdges()
|
||||
{
|
||||
// Arrange
|
||||
var planner = new DifferentialPlanner();
|
||||
var (nodes, edges) = TestHelpers.CreateSimpleLinearGraph();
|
||||
|
||||
// Act & Assert - Should not throw
|
||||
planner.SetData(nodes, edges);
|
||||
Assert.True(true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IPathPlanner_SetOptions_ShouldAcceptOptions()
|
||||
{
|
||||
// Arrange
|
||||
var planner = new DifferentialPlanner();
|
||||
var options = new PathPlannerOptions
|
||||
{
|
||||
LimitDistanceToEdge = 1.0,
|
||||
LimitDistanceToNode = 0.3
|
||||
};
|
||||
|
||||
// Act & Assert - Should not throw
|
||||
planner.SetOptions(options);
|
||||
Assert.True(true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IPathPlanner_AllPathPlanningMethods_ShouldReturnTuple()
|
||||
{
|
||||
// Arrange
|
||||
var planner = new DifferentialPlanner();
|
||||
var (nodes, edges) = TestHelpers.CreateSimpleLinearGraph();
|
||||
planner.SetData(nodes, edges);
|
||||
|
||||
var x = 0.0;
|
||||
var y = 0.0;
|
||||
var theta = 0.0;
|
||||
var goalId = nodes[2].Id;
|
||||
|
||||
// Act
|
||||
var result1 = planner.PathPlanning(x, y, theta, goalId);
|
||||
var result2 = planner.PathPlanningWithStartDirection(x, y, theta, goalId);
|
||||
var result3 = planner.PathPlanningWithFinalDirection(x, y, theta, goalId);
|
||||
var result4 = planner.PathPlanningWithAngle(x, y, theta, goalId, 90.0);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result1.Nodes);
|
||||
Assert.NotNull(result1.Edges);
|
||||
Assert.NotNull(result2.Nodes);
|
||||
Assert.NotNull(result2.Edges);
|
||||
Assert.NotNull(result3.Nodes);
|
||||
Assert.NotNull(result3.Edges);
|
||||
Assert.NotNull(result4.Nodes);
|
||||
Assert.NotNull(result4.Edges);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user