This test project contains comprehensive unit tests for the JoinFS application.
The Program.Code(...) method is a bidirectional cipher that implements encoding and decoding functionality using:
- Caesar substitution cipher
- Pseudo-random number generation with seeded keys
- Character range validation (printable ASCII characters from '!' to '~')
-
Null and Empty String Tests
- Validates handling of null inputs
- Validates handling of empty strings
-
Round-Trip Tests
- Ensures encoding followed by decoding restores the original string
- Tests various common input patterns (URLs, file paths, email addresses, etc.)
- Tests all printable ASCII characters
-
Key Sensitivity Tests
- Verifies different keys produce different encodings
- Confirms wrong keys cannot decode messages
- Validates key consistency
-
Special Character Tests
- Tests boundary characters ('!' and '~')
- Tests mixed special character strings
-
Edge Cases with Invalid Characters
- Handles characters outside the valid range
- Properly trims invalid characters at boundaries
-
Encoding/Decoding Properties
- Verifies encoding produces different output
- Confirms deterministic behavior (same input + key = same output)
- Validates encoded string length
-
Multiple Round-Trips
- Ensures data integrity over multiple encode/decode cycles
-
Real-World Usage Scenarios
- Tests with URLs, file paths, and long strings
-
Key Value Tests
- Tests with various key values including edge cases (0, negative, max/min int)
The EnrichModelService class handles enrichment of aircraft model data through API calls and local caching.
-
Constructor Tests
- Validates initialization with valid and invalid file paths
- Tests loading of existing data from JSONL files
- Handles malformed JSON lines gracefully
- Skips entries with null or empty titles
-
QueryAndStoreModelDetailsAsync Tests
- Verifies API is not called for empty lists
- Skips already loaded models to avoid redundant API calls
- Correctly queries API for new models
- Batches large requests (20 models per batch)
- Saves enriched data to JSONL file
- Handles duplicate titles correctly
-
EnrichModelsWithDetailsAsync Tests
- Enriches multiple models in a single operation
- Handles null models gracefully
- Handles empty or whitespace titles
- Uses distinct titles to minimize API calls
-
EnrichModel Tests
- Synchronous enrichment of single models
- Null-safety for null models and empty titles
- Uses cached data when available
The EmbeddingService class provides BERT-based text embeddings for semantic similarity calculations. These tests are only compiled and run on x64 platforms.
-
Normalize Tests
- Normalizes vectors to unit length
- Handles unit vectors correctly
- Gracefully handles zero vectors
- Verifies normalized vectors have magnitude 1.0
-
MeanPooling Tests
- Calculates correct mean pooling over token embeddings
- Respects attention mask to skip padding tokens
- Handles cases with all valid tokens
- Handles single valid token cases
-
CosineSimilarity Tests
- Returns 1.0 for identical vectors
- Returns 0.0 for orthogonal vectors
- Returns -1.0 for opposite vectors
- Handles scaled vectors correctly
- Validates that similarity is always in range [-1, 1]
- Throws exception for different length vectors
-
FindBestMatchingModel Tests
- Returns null when no match exceeds threshold
- Correctly identifies the best matching model
- Skips models without embeddings
To run all tests:
cd JoinFS.Tests
dotnet testTo run tests with verbose output:
dotnet test --verbosity normalTo run tests with coverage:
dotnet test --collect:"XPlat Code Coverage"All 53 tests pass successfully, providing comprehensive coverage of:
- ProgramCode: 34 tests covering encoding/decoding functionality
- EnrichModelService: 16 tests covering model enrichment with API integration
- EmbeddingService: 3 test classes covering mathematical operations (x64 only)
The test suite covers:
- Normal operation
- Edge cases
- Error conditions
- Null safety
- Round-trip operations
- Mock HTTP client interactions
- File I/O operations
The test project includes standalone copies of the classes being tested to avoid circular dependencies with the main Windows Forms application. This ensures the tests can run independently on any platform (including non-Windows CI/CD environments).
- Most tests run on all platforms (x86 and x64)
- EmbeddingService tests only run on x64 due to ML.OnnxRuntime platform requirements
- The test project uses conditional compilation (
#if X64) to handle platform-specific code