Testable Architecture of Grade My Investments
Comprehensive testing strategy with 695 unit and integration tests ensuring robust, reliable, and maintainable code.
Testing Philosophy
The Grade My Investments platform is built with testability as a core architectural principle. Every component, service, and integration point is designed to be testable in isolation, enabling rapid development cycles, confident refactoring, and reliable deployments.
Our comprehensive test suite of 695 tests (583 unit + 95 integration + 17 engine) covers critical business logic, data access patterns, API endpoints, authentication, authorization, and integration points, ensuring system reliability and facilitating continuous delivery.
flowchart TB
subgraph UNIT[Gmi.UnitTests - 583 tests]
U1[Services - 335]:::svc
U2[Repositories - 145]:::svc
U3[Azure Functions - 116]:::svc
end
subgraph INT[Gmi.DataAccess.IntegrationTests - 95 tests]
I1[EF Core - Repositories]:::data
I2[CRUD Operations]:::data
end
subgraph ENG[Gmi.ReportEngine.Tests - 17 tests]
E1[Financial Calculations]:::svc
E2[Report Accuracy]:::svc
end
subgraph TOOLS[Test Tools]
T1([xUnit]):::ext
T2([Moq]):::ext
T3([FluentAssertions]):::ext
T4([EF InMemory]):::ext
end
subgraph CICD[CI - CD Gate]
P[Azure DevOps Pipeline]:::sec
Q{All Pass?}:::sec
end
UNIT --> P
INT --> P
ENG --> P
P --> Q
Q -->|yes| R([Deploy]):::app
Q -->|no| S([Block Deploy]):::app
TOOLS -.->|power| UNIT
TOOLS -.->|power| INT
classDef app fill:#1f2630,stroke:#C0894E,color:#F3EFE8;
classDef svc fill:#241c14,stroke:#E2B583,color:#F3EFE8;
classDef data fill:#22201a,stroke:#C0894E,color:#EBD3AE;
classDef ext fill:#1b1f27,stroke:#5A616B,color:#C4C0B8;
classDef sec fill:#1d2733,stroke:#5cc8e0,color:#eafaff;
Test Project Structure
| Test Project | Target Components | Test Count | Coverage Focus |
|---|---|---|---|
Gmi.UnitTests |
Services, API functions, repositories | 583 tests | Business rules, data validation, API contracts |
Gmi.DataAccess.IntegrationTests |
Entity Framework, repositories, database operations | 95 tests | Data access patterns, CRUD operations |
Gmi.ReportEngine.Tests |
Report generation engine, calculations | 17 tests | Financial calculations, report accuracy |
Testing Patterns & Practices
Dependency Injection
- • Services designed for DI container
- • Interface-based abstractions
- • Easy mocking and stubbing
- • Isolated unit testing
Repository Pattern
- • Abstracted data access
- • In-memory test repositories
- • Database-independent tests
- • Fast test execution
Service Layer Testing
- • Business logic isolation
- • Mocked external dependencies
- • End-to-end scenario testing
- • Error handling validation
Calculation Engine Testing
- • Mathematical precision validation
- • Edge case boundary testing
- • Performance benchmarking
- • Historical data accuracy
Test Categories & Coverage
Unit Tests
- Services (335 tests) 335 tests
- Repositories (145 tests) 145 tests
- Azure Functions (116 tests) 116 tests
Integration & Engine Tests
- Database Integration (95 tests) 95 tests
- Report Engine (17 tests) 17 tests
Testing Tools & Frameworks
xUnit
Primary testing framework for .NET projects
Moq
Mocking framework for dependencies and external services
FluentAssertions
Readable and expressive test assertions
Entity Framework InMemory
In-memory database for fast data access testing
BenchmarkDotNet
Performance testing and benchmarking
Coverlet
Code coverage analysis and reporting
Test Metrics
- Total Tests: 695 tests
- Code Coverage: 89%
- Pass Rate: 99.8%
- Execution Time: < 3 minutes
- Critical Path Coverage: 100%
- Business Logic Coverage: 95%
Testing Benefits
- Rapid development cycles
- Confident refactoring
- Early bug detection
- Regression prevention
- Documentation via tests
- Deployment confidence
CI/CD Integration
All tests run automatically on every pull request and deployment, ensuring code quality gates are maintained.
- Pre-commit hooks
- PR validation
- Azure DevOps pipeline
- Quality gates