Introduced `ZugferdController` to handle ZUGFeRD-related operations, including detection and extraction of ZUGFeRD XML from PDFs via file upload or Base64-encoded payloads. Integrated `MediatR` for query/command handling.
Added `ZugferdSettings` for configurable file names and patterns, and updated `appsettings.json` and `Program.cs` to support this configuration.
Implemented `HasZugferdQuery` and `ExtractZugferdCommand` with their respective handlers and validators. Added DTOs (`ZugferdCheckResult`, `ZugferdExtractionResult`) for operation results.
Included `ZUGFeRD-Example.pdf` for testing and integrated `Serilog.Ui.Core.Extensions` for logging.
Application Handler Tests:
- ValidatePdfHandlerTests: PdfStream = new MemoryStream(pdfBytes)
- ValidatePdfAQueryHandlerTests: PdfStream = new MemoryStream(pdfBytes)
- CheckPdfAttachmentsQueryHandlerTests: PdfStream = new MemoryStream(pdfBytes)
- Remove Base64/PdfBytes property usage
Infrastructure Tests:
- DevExpressSwissQrCodeProcessorTests: LoadTestPdf() returns Stream
- All test methods use 'using var stream' pattern
- Add test: ExtractSwissQrCodeAsync_StreamNotAtBeginning_ThrowsBadRequestException
Result: All unit tests pass with Stream-based API
- Unit tests for CheckPdfAttachmentsQueryHandler (3 tests)
- Integration tests for PdfAttachmentController (14 tests covering both multipart and JSON endpoints)
- Tests verify: attachment detection, metadata extraction, empty PDF handling, validation errors
- All tests using Stream API (mocks with It.IsAny<Stream>())
- Total: 17 new tests, all passing
- Update unit tests to assert (Bill, string[]) tuple return
- Update integration tests for new response structure (Bill + RawLines)
- Fix exception message assertion in DevExpressSwissQrCodeProcessorTests
- All 34 tests passing, 6 skipped (require real Swiss QR Bill PDFs)
Integration test updates:
- PdfValidationControllerTests.cs (new)
- Test /api/pdf/validation/validate endpoint
- Test BOTH multipart/form-data AND Base64 JSON
- ExtractSwissQrCodeEndpointTests.cs (updated)
- Update endpoint path to /api/swissqrcode/extract
- Test BOTH input formats
Unit test updates:
- ValidatePdfHandlerTests.cs:
- Update for Query + Handler co-location
- Test AutoMapper integration
- ExtractSwissQrCodeHandlerTests.cs:
- Update for Query + Handler co-location
- Test AutoMapper integration
Deleted:
- DocumentEndpointsTests.cs (Minimal API tests, no longer relevant)
Result: 20/20 tests passing, Controller endpoint coverage
Added a new `/extract-swiss-qr-code` endpoint to extract and parse Swiss QR Codes from the last page of a PDF document. Implemented the `ExtractSwissQrCode` handler method, along with helper methods to map domain value objects (`SwissQrCodeData` and `AddressData`) to DTOs.
Updated `ExceptionHandlingMiddleware` to handle the new `SwissQrCodeNotFoundException` with a 404 Not Found response.
Added integration tests in `ExtractSwissQrCodeEndpointTests` to validate the endpoint's behavior for valid requests, invalid Base64 input, empty references, and empty PDFs. Introduced a helper method to load embedded PDF resources as Base64 strings for testing.
Updated `using` directives to include necessary namespaces for the new feature and exception handling.
Introduced DTOs for request and response to handle Swiss QR Code extraction from PDF documents. Implemented `ExtractSwissQrCodeHandler` to process the extraction using `ISwissQrCodeProcessor`. Added validation for the query with `ExtractSwissQrCodeValidator`. Developed unit tests to ensure correct behavior for successful and failure scenarios.
Refactored `DevExpressPdfProcessor` to improve attachment detection:
- Changed `DetectEmbeddedFiles` return type to a tuple for better
handling of attachment presence and count.
- Enhanced logic to parse `/Names` arrays and count object references
for accurate attachment detection.
- Implemented robust search for `/EmbeddedFiles` to handle multiple
occurrences and ensure proper context validation.
Updated PHASENPLAN.md and ROADMAP.md to reflect these changes, including
the addition of fixes for attachment detection and counting logic.
Added new tests in `DevExpressPdfProcessorTests`:
- Verified detection of multiple attachments and accurate counts.
- Ensured no crashes when processing PDFs with `/EmbeddedFiles`.
Included a new test resource (`pdfWithMoreThanOneAttachment.pdf`) for
validating multiple attachment scenarios.
Updated PHASENPLAN.md and ROADMAP.md to reflect a complete restructuring of the development plan and added a "Bugfix: Attachment Detection" entry.
Implemented attachment detection in DevExpressPdfProcessor.cs using the new `DetectEmbeddedFiles` method, which scans raw PDF data for the `/EmbeddedFiles` keyword. Updated the `hasAttachments` property to use this method and set `attachmentCount` to `-1` when attachments are detected.
Added a new test, `ValidateAsync_PdfWithoutAttachments_ReturnsNoAttachments`, in DevExpressPdfProcessorTests.cs to verify that PDFs without attachments are correctly identified. Included a note about future testing for PDFs with attachments using ZUGFeRD files.
All related tests are passing (12/12 green).
Implemented the ValidatePDF feature end-to-end:
- Added `/api/v1/documents/validate` Minimal API endpoint.
- Introduced centralized ExceptionHandlingMiddleware.
- Configured Swagger with `AddSwaggerDocumentation` extension.
- Enabled XML comments in `DocumentOperator.API.csproj`.
- Updated DTOs with XML comments and added `FileSizeMB`.
- Added integration tests for the ValidatePDF endpoint (3 tests).
- Registered infrastructure services (e.g., `IPdfProcessor`).
- Refactored `Program.cs` to include middleware and endpoints.
- Updated PHASENPLAN.md and ROADMAP.md to reflect progress.
- Cleaned up code and made `Program` accessible for tests.
Updated PHASENPLAN and ROADMAP to reflect progress on Feature 1 - ValidatePDF (75% complete). Marked Step 1.1 as completed, including MediatR setup, pipeline behaviors (`ValidationBehavior`, `LoggingBehavior`), ValidatePDF feature (Query, Handler, Validator), and DTOs.
Added `DependencyInjection.cs` for Application Layer DI configuration. Introduced `LoggingBehavior` and `ValidationBehavior` for MediatR pipelines. Implemented `ValidatePdfHandler`, `ValidatePdfQuery`, and `ValidatePdfValidator`.
Created DTOs (`ValidatePdfRequest`, `ValidatePdfResponse`) for the ValidatePDF feature. Added unit tests for `ValidatePdfHandler` to verify metadata handling and exception propagation.
Removed unused folder references in `DocumentOperator.Application.csproj`.
Replaced `DevExpress.Pdf.Core` with `DevExpress.Document.Processor` in `DocumentOperator.Infrastructure.csproj` to adopt a newer library for PDF processing. Removed the `Services\PdfProcessing\` folder reference.
Updated `DevExpressPdfProcessorTests` to reflect changes in the `ValidateAsync` method's behavior.
Introduced the `DevExpressPdfProcessor` class, implementing the `IPdfProcessor` interface. This class validates PDF documents and extracts metadata using the `DevExpress.Pdf` library. Added defensive input validation, metadata extraction, and exception handling for domain consistency.
Updated ROADMAP.md to reflect progress on the TDD process for
DevExpressPdfProcessor, including the creation of unit tests
(6 tests in the Red Phase). Updated progress to 4/7 mini-steps
completed and outlined the next step (Green Phase).
Added `DevExpressPdfProcessorTests.cs` with unit tests to
validate PDF files and extract metadata. Tests cover valid
PDFs, null/empty inputs, corrupted PDFs, and file size
calculations. Used `FluentAssertions` for assertions.
Cleaned up `DocumentOperator.Tests.csproj` by removing an
unused folder reference. No functional changes to the project
structure.
Updated ROADMAP.md to reflect progress on Phase 3, Step 3.2:
- Created test folder structure under Unit/Infrastructure/Services/PdfProcessing.
- Updated progress status to 2/7 mini-steps completed.
- Documented next step (adding a test PDF file) and marked DevExpressPdfProcessor.cs implementation as "IN PROGRESS."
- Highlighted availability of the DevExpress Universal License.
Modified DocumentOperator.Tests.csproj:
- Added the new test folder structure to the project file.
The `UnitTest1` class in the `DocumentOperator.Tests` namespace was removed, including the `Test1` method, which was an empty test marked with the `[Fact]` attribute. This cleanup suggests the test class is no longer needed or has been replaced by other tests.
Updated `Microsoft.NET.Test.Sdk` to version 17.11.1 and `xunit` to version 2.9.3. Updated `xunit.runner.visualstudio` to version 2.8.2 with additional metadata for asset inclusion and private asset behavior.
Added new dependencies: `FluentAssertions` (7.0.0) and `Moq` (4.20.72).
Introduced project references to `DocumentOperator.Domain`, `DocumentOperator.Application`, and `DocumentOperator.Infrastructure` to the test project.
No changes were made to the `coverlet.collector` dependency or the `<Using Include="Xunit" />` directive.
Added a new test project, `DocumentOperator.Tests`, to the solution targeting .NET 8.0. Configured the project as a non-packable test project with support for nullable reference types and implicit usings. Included dependencies for `xunit`, `Microsoft.NET.Test.Sdk`, and `coverlet.collector` for testing and code coverage.
Added a placeholder test class, `UnitTest1`, with a single test method, `Test1`, marked with the `[Fact]` attribute.