diff --git a/doc/architecture/Managers/ConfigManager.md b/doc/architecture/managers/ConfigManager.md similarity index 64% rename from doc/architecture/Managers/ConfigManager.md rename to doc/architecture/managers/ConfigManager.md index 3fcdc95..664b54f 100644 --- a/doc/architecture/Managers/ConfigManager.md +++ b/doc/architecture/managers/ConfigManager.md @@ -131,85 +131,3 @@ ssl = false min_connections = 1 max_connections = 10 ``` - ---- - -## Unit Tests - -Unit tests for `ConfigManager` are implemented in `src/g2_2025_grade_calculator_pkg/test/ConfigManager.test.cpp` using Google Test and ROS2 test utilities. The tests use temporary TOML files to validate configuration loading and parsing functionality. - -### Test Cases - -#### 1. ConstructorTest - -**Description:** Verifies that ConfigManager can be created with a ROS2 logger without crashing. - -- **Test Action:** Create ConfigManager instance with ROS2 logger -- **Expected Result:** Instance created successfully without exceptions - -#### 2. LoadValidConfigTest - -**Description:** Tests loading of valid TOML configuration files with proper parsing. - -- **Test Action:** - - Create temporary TOML file with valid configuration - - Call `load_config()` with file path -- **Expected Result:** - - Returns `true` - - `is_loaded()` returns `true` - -#### 3. LoadInvalidFileTest - -**Description:** Tests error handling when attempting to load non-existent configuration files. - -- **Test Action:** Call `load_config()` with non-existent file path -- **Expected Result:** - - Returns `false` - - `is_loaded()` returns `false` - -#### 4. DatabaseConfigParsingTest - -**Description:** Tests complete database configuration parsing with all parameters. - -- **Test Configuration:** - ```toml - [database] - host = "test_host" - port = 1234 - dbname = "test_db" - user = "test_user" - password = "test_password" - timeout = 60 - ssl = true - - [database.pool] - min_connections = 2 - max_connections = 20 - ``` -- **Expected Result:** All configuration values parsed correctly with proper types - -#### 5. DatabaseConfigWithoutPoolTest - -**Description:** Tests default values when optional pool section is missing from configuration. - -- **Test Configuration:** - ```toml - [database] - host = "localhost" - port = 5432 - dbname = "grades" - user = "postgres" - password = "postgres" - ``` -- **Expected Result:** - - Main database config parsed correctly - - Default pool values: `min_connections = 1`, `max_connections = 10` - -#### 6. GetConfigWithoutLoadingTest - -**Description:** Tests behavior when attempting to access configuration before loading any file. - -- **Test Action:** Call `get_database_config()` without loading configuration -- **Expected Result:** - - Returns `std::nullopt` - - `is_loaded()` returns `false` diff --git a/doc/architecture/Managers/DatabaseManager.md b/doc/architecture/managers/DatabaseManager.md similarity index 64% rename from doc/architecture/Managers/DatabaseManager.md rename to doc/architecture/managers/DatabaseManager.md index cd14e56..a4bc1d1 100644 --- a/doc/architecture/Managers/DatabaseManager.md +++ b/doc/architecture/managers/DatabaseManager.md @@ -123,69 +123,3 @@ if (db_manager.is_connected()) { } } ``` - ---- - -## Unit Tests - -Unit tests for `DatabaseManager` are implemented in `src/g2_2025_grade_calculator_pkg/test/DatabaseManager.test.cpp` using Google Test and ROS2 test utilities. The tests are designed to work reliably whether a database connection is available or not, focusing on error handling and method behavior validation. - -### Test Cases - -#### 1. ConstructorTest - -**Description:** Verifies that DatabaseManager can be created without crashing and proper initialization occurs. - -- **Test Action:** Create DatabaseManager instance with ROS2 logger -- **Expected Result:** Instance created successfully without exceptions - -#### 2. ConnectionStatusTest - -**Description:** Tests that the `is_connected()` method returns a valid boolean value. - -- **Test Action:** Call `is_connected()` method -- **Expected Result:** Returns either `true` or `false` (no crashes or invalid states) - -#### 3. QueuePendingCombinationsTest - -**Description:** Verifies retrieval of pending student-course combinations that need exam results. - -- **Test Action:** Call `queue_pending_combinations()` -- **Expected Result:** Returns valid vector (empty if no database connection, populated if connected) - -#### 4. StoreExamResultTest - -**Description:** Tests exam result storage with graceful handling of connection states. - -- **Test Action:** - - Student: `"TestStudent"` - - Course: `"TestCourse"` - - Grade: `85` -- **Expected Result:** Returns `false` if no connection, `true` if connected and successful - -#### 5. EnrollStudentTest - -**Description:** Tests student enrollment into courses. - -- **Test Action:** - - StudentCourse object with test data -- **Expected Result:** Returns `false` if no connection, `true` if connected and successful - -#### 6. GetFinalGradeTest - -**Description:** Tests final grade retrieval for non-existent student-course combinations. - -- **Test Action:** - - Student: `"NonExistentStudent"` - - Course: `"NonExistentCourse"` -- **Expected Result:** Returns `-1` (no results found or no connection) - -#### 7. StoreFinalResultTest - -**Description:** Tests storing calculated final course results. - -- **Test Action:** - - StudentCourse object - - Exam count: `3` - - Final grade: `75` -- **Expected Result:** Returns `false` if no connection, `true` if connected and successful diff --git a/doc/Tests/ConfigManager.md b/doc/tests/ConfigManager.md similarity index 100% rename from doc/Tests/ConfigManager.md rename to doc/tests/ConfigManager.md diff --git a/doc/Tests/DatabaseManager.md b/doc/tests/DatabaseManager.md similarity index 100% rename from doc/Tests/DatabaseManager.md rename to doc/tests/DatabaseManager.md diff --git a/doc/Tests/ExamResultGenerator.md b/doc/tests/ExamResultGenerator.md similarity index 100% rename from doc/Tests/ExamResultGenerator.md rename to doc/tests/ExamResultGenerator.md diff --git a/doc/Tests/FinalGradeDeterminator.md b/doc/tests/FinalGradeDeterminator.md similarity index 100% rename from doc/Tests/FinalGradeDeterminator.md rename to doc/tests/FinalGradeDeterminator.md diff --git a/doc/Tests/GradeCalculator.md b/doc/tests/GradeCalculator.md similarity index 100% rename from doc/Tests/GradeCalculator.md rename to doc/tests/GradeCalculator.md diff --git a/src/g2_2025_grade_calculator_pkg/launch/grade_calculator.launch.xml b/src/g2_2025_grade_calculator_pkg/launch/grade_calculator.launch.xml index d3c66b4..ab2ff34 100644 --- a/src/g2_2025_grade_calculator_pkg/launch/grade_calculator.launch.xml +++ b/src/g2_2025_grade_calculator_pkg/launch/grade_calculator.launch.xml @@ -1,5 +1,7 @@ - + + +