test: Add PDF/A validation tests and manual testing guide
- Add unit tests for ValidatePdfAQueryHandler (4 tests) - Add integration tests for PDF/A validation endpoint (6 tests) - Fix FluentValidation: Add Base64 format validation to ValidatePdfAQueryValidator - Update AGENTS.md: Document 3-folder test structure rationale and test count (30 tests) - Add DocumentOperator.API/README.md: 16 manual test scenarios for all endpoints Test coverage: - Unit: ValidatePdfAQueryHandler (compliant, non-compliant, encrypted, exceptions) - Integration: PDF/A endpoint (multipart + Base64, validation, error handling) - Manual: Step-by-step Swagger UI testing guide for all features All 30 automated tests passing.
This commit is contained in:
59
AGENTS.md
59
AGENTS.md
@@ -188,7 +188,7 @@ After completing all Phase 1-3 controllers (PdfValidation, PdfAttachment, SwissQ
|
||||
dotnet build
|
||||
```
|
||||
|
||||
**Run tests (19 tests as of Feature 2):**
|
||||
**Run tests (30 tests as of Feature 3 - PDF/A Validation):**
|
||||
```powershell
|
||||
dotnet test
|
||||
```
|
||||
@@ -273,7 +273,7 @@ Do NOT add `if (result.IsSuccess)` checks. Throw exceptions for errors. The midd
|
||||
|
||||
| Controller | Status | Tests |
|
||||
|-----------|--------|-------|
|
||||
| **PdfValidationController** | ✅ Partial (validate done, validate-pdfa pending) | 4 |
|
||||
| **PdfValidationController** | ✅ DONE | 13 (7 validate + 6 validate-pdfa) |
|
||||
| **SwissQrCodeController** | ✅ DONE | 2 |
|
||||
| **PdfAttachmentController** | ⏳ Pending | 0 |
|
||||
| **PdfOperationsController** | ⏳ Pending | 0 |
|
||||
@@ -333,6 +333,61 @@ var stream = Assembly.GetExecutingAssembly()
|
||||
|
||||
---
|
||||
|
||||
## Test Structure & Strategy
|
||||
|
||||
**3-folder structure (CORRECT approach by previous developer):**
|
||||
|
||||
```
|
||||
DocumentOperator.Tests/
|
||||
├── Integration/
|
||||
│ └── API/
|
||||
│ ├── PdfValidationControllerTests.cs (13 tests)
|
||||
│ └── ExtractSwissQrCodeEndpointTests.cs (2 tests)
|
||||
├── TestData/
|
||||
│ └── Pdfs/ (EmbeddedResource PDFs)
|
||||
├── Unit/
|
||||
│ ├── Application/
|
||||
│ │ └── Features/
|
||||
│ │ ├── ValidatePdf/
|
||||
│ │ │ └── ValidatePdfHandlerTests.cs (2 tests)
|
||||
│ │ ├── ValidatePdfA/
|
||||
│ │ │ └── ValidatePdfAQueryHandlerTests.cs (4 tests)
|
||||
│ │ └── ExtractSwissQrCode/
|
||||
│ │ └── ExtractSwissQrCodeHandlerTests.cs (2 tests)
|
||||
│ └── Infrastructure/
|
||||
│ └── Services/
|
||||
│ └── PdfProcessing/
|
||||
│ └── DevExpressPdfProcessorTests.cs (7 tests)
|
||||
```
|
||||
|
||||
**✅ Why this structure is CORRECT:**
|
||||
|
||||
1. **Integration vs Unit separation:**
|
||||
- **Integration:** WebApplicationFactory → REAL API calls (HTTP, middleware, MediatR pipeline, DevExpress)
|
||||
- **Unit:** Mock-based ISOLATED tests (Handler only depends on mocked IPdfProcessor)
|
||||
|
||||
2. **TestData centralization:**
|
||||
- All 3 layers share same EmbeddedResource PDFs (no duplication)
|
||||
- Accessed via `Assembly.GetManifestResourceStream()`
|
||||
|
||||
3. **Vertical Slice compliance:**
|
||||
- `Unit/Application/Features/ValidatePdf/` → Each feature's tests co-located
|
||||
- Matches Application layer structure exactly
|
||||
|
||||
4. **Test Pyramid:**
|
||||
- **Unit tests (15):** Fast, isolated, many scenarios
|
||||
- **Integration tests (15):** Slower, full pipeline, critical paths only
|
||||
|
||||
**Test count:** 30 tests total (as of Feature 3 - PDF/A Validation)
|
||||
|
||||
**FluentValidation in tests:**
|
||||
- Base64 format validation happens in `ValidatePdfQueryValidator` and `ValidatePdfAQueryValidator`
|
||||
- Prevents `FormatException` from reaching handler (caught as 400 Bad Request, not 500)
|
||||
- Unit tests verify handler behavior with valid inputs only
|
||||
- Integration tests verify full validation pipeline (including FluentValidation)
|
||||
|
||||
---
|
||||
|
||||
## Swiss QR Code Feature (Feature 2)
|
||||
|
||||
**Swiss QR Bill Standard 2.0** requires:
|
||||
|
||||
Reference in New Issue
Block a user