Initial commit

This commit is contained in:
2026-07-13 09:25:40 +07:00
parent c08ff54676
commit bccfb156d7
1938 changed files with 641646 additions and 0 deletions

View File

@@ -0,0 +1,149 @@
# Unit Tests - RobotNet10.GlobalPathPlanner
Thư mục này chứa các unit tests cho project `RobotNet10.GlobalPathPlanner`.
## 📁 Cấu trúc Tests
```
RobotNet10.GlobalPathPlanner.Test/
├── TestHelpers.cs # Helper methods để tạo test data
├── PathPlannerFactoryTests.cs # Tests cho PathPlannerFactory
├── DifferentialPlannerTests.cs # Tests cho DifferentialPlanner
├── GlobalNodeTests.cs # Tests cho GlobalNode model
├── GlobalEdgeTests.cs # Tests cho GlobalEdge model
├── PathPlannerOptionsTests.cs # Tests cho PathPlannerOptions
├── OrientationTests.cs # Tests cho Orientation enum
├── IPathPlannerTests.cs # Tests cho IPathPlanner interface
├── README.md # File này
└── HOW_TO_RUN_TESTS.md # Hướng dẫn chi tiết chạy tests
```
## 🧪 Test Coverage
### ✅ Đã được test
1. **PathPlannerFactory**
- Tạo các loại planner khác nhau
- Kiểm tra instance types
- Kiểm tra mỗi lần tạo là instance mới
2. **DifferentialPlanner**
- SetData và SetOptions
- PathPlanning từ tọa độ
- PathPlanning từ Node ID
- PathPlanning với direction constraints
- PathPlanning với angle constraints
- Error handling (invalid goal, disconnected graph)
- Timeout và cancellation
- Edge cases (same start/goal, empty arrays)
3. **GlobalNode**
- DistanceTo calculations
- Property setters
- ToString method
4. **GlobalEdge**
- Property setters
- Record equality
- Degree values (1, 2, 3)
5. **PathPlannerOptions**
- Default values
- Property setters
- Record equality
- TimeOut handling
6. **Orientation**
- Enum values
- Assignment to nodes
7. **IPathPlanner Interface**
- Interface contract
- Method implementations
## 🚀 Chạy Tests
### Sử dụng Visual Studio
1. Mở Test Explorer (Test → Test Explorer)
2. Build solution
3. Chọn tests cần chạy và click "Run"
### Sử dụng dotnet CLI
```bash
cd srcs/RobotNet10/Tests/RobotNet10.GlobalPathPlanner.Test
dotnet test
```
### Chạy tests cụ thể
```bash
dotnet test --filter "FullyQualifiedName~DifferentialPlannerTests"
```
## 📊 Test Statistics
- **Total Tests**: ~40+ test cases
- **Test Framework**: xUnit
- **Coverage Areas**:
- Factory pattern
- Path planning algorithms
- Data models
- Error handling
- Edge cases
## 🛠️ Test Helpers
`TestHelpers.cs` cung cấp các helper methods để tạo test data:
- `CreateSimpleLinearGraph()` - Graph đơn giản 3 nodes thẳng hàng
- `CreateSquareGraph()` - Graph hình vuông 4 nodes
- `CreateDisconnectedGraph()` - Graph không liên thông (để test error cases)
- `CreateBezierCurveGraph()` - Graph với Bezier curves
## 📝 Best Practices
1. **AAA Pattern**: Arrange, Act, Assert
2. **Test Isolation**: Mỗi test độc lập, không phụ thuộc vào test khác
3. **Meaningful Names**: Tên test mô tả rõ behavior được test
4. **Test Data**: Sử dụng TestHelpers để tạo consistent test data
5. **Edge Cases**: Test cả success và failure scenarios
## 🔍 Test Categories
### Unit Tests
- Test từng component riêng biệt
- Mock dependencies nếu cần
- Fast execution
### Integration Tests (Future)
- Test interaction giữa các components
- Test với real data
- Test end-to-end scenarios
## 📈 Coverage Goals
- [x] PathPlannerFactory: 100%
- [x] DifferentialPlanner core methods: ~90%
- [x] Data models: 100%
- [ ] ForkliftPlanner: Pending
- [ ] ForkliftPlannerV2: Pending
- [ ] AStarPlanner: Pending
- [ ] MathExtensions: Pending
## 🐛 Known Issues
- Timeout tests có thể không consistent trên các hệ thống khác nhau
- Một số tests phụ thuộc vào performance của A* algorithm
## 🤝 Contributing
Khi thêm tests mới:
1. Follow naming convention: `MethodName_Scenario_ExpectedBehavior`
2. Sử dụng TestHelpers cho test data
3. Thêm comments cho complex test cases
4. Đảm bảo tests chạy độc lập
## 📚 Resources
- [xUnit Documentation](https://xunit.net/)
- [.NET Testing Best Practices](https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-best-practices)