Compare commits
4 Commits
cdb942210c
...
196f6d9cfb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
196f6d9cfb | ||
|
|
498b6758bf | ||
|
|
49d1f43822 | ||
|
|
3a87ace144 |
@@ -726,10 +726,12 @@ DocumentOperator.Tests/
|
||||
|
||||
---
|
||||
|
||||
### ?? PHASE 2: Domain Layer (Minimal) - **IN PROGRESS**
|
||||
### ? PHASE 2: Domain Layer (Minimal) - **COMPLETED**
|
||||
|
||||
**Ziel:** Nur was wirklich gebraucht wird!
|
||||
|
||||
**Status:** ? **Alle Steps abgeschlossen!**
|
||||
|
||||
---
|
||||
|
||||
#### ? Step 2.1: Domain Exceptions erstellen - **COMPLETED**
|
||||
@@ -802,7 +804,7 @@ DocumentOperator.Tests/
|
||||
|
||||
---
|
||||
|
||||
#### ?? Step 2.3: Value Objects erstellen - **NEXT**
|
||||
#### ? Step 2.3: Value Objects erstellen - **COMPLETED**
|
||||
|
||||
**Aufgabe:** Typsichere, selbst-validierende Wert-Objekte
|
||||
|
||||
@@ -812,49 +814,58 @@ DocumentOperator.Tests/
|
||||
- ? Immutable (keine Änderungen nach Erstellung)
|
||||
- ? Wiederverwendbar (in Domain, Application, Infrastructure)
|
||||
|
||||
**Was du erstellen wirst:**
|
||||
**Was du erstellt hast:**
|
||||
|
||||
1. **Base64String.cs**
|
||||
1. **Base64String.cs** ?
|
||||
- Factory Method: `Create(string value)`
|
||||
- Validierung: Gültiges Base64-Format
|
||||
- Konvertierung: `ToByteArray()`, `FromByteArray(byte[])`
|
||||
- Wirft `DomainValidationException` bei Fehler
|
||||
|
||||
2. **TenantId.cs**
|
||||
2. **TenantId.cs** ?
|
||||
- Factory Method: `Create(string value)`
|
||||
- Validierung: Nicht leer, Max 100 Zeichen
|
||||
- Normalisierung: `.ToLowerInvariant()`
|
||||
- Wirft `DomainValidationException` bei Fehler
|
||||
|
||||
3. **PdfMetadata.cs**
|
||||
3. **PdfMetadata.cs** ?
|
||||
- Properties: PageCount, FileSizeBytes, PdfVersion, HasAttachments, AttachmentCount
|
||||
- Computed Property: `FileSizeMB`
|
||||
- Keine Validierung (nur Daten-Container)
|
||||
|
||||
**Wo:** `Domain/Models/ValueObjects/`
|
||||
|
||||
**Detaillierte Anleitung kommt in Step 2.3!**
|
||||
**Status:** ? **COMPLETED** (17.01.2025)
|
||||
- ? Base64String.cs erstellt (sealed, Factory Methods, Validierung, Equality)
|
||||
- ? TenantId.cs erstellt (sealed, Normalisierung, Validierung, Equality)
|
||||
- ? PdfMetadata.cs erstellt (sealed, Computed Property, ToString())
|
||||
- ? Build erfolgreich
|
||||
|
||||
**?? Phase 2 (Domain Layer) komplett abgeschlossen!**
|
||||
|
||||
---
|
||||
|
||||
### ? PHASE 3: Infrastructure Layer (Outside-In!)
|
||||
### ? PHASE 3: Infrastructure Layer (Outside-In!) - **NEXT**
|
||||
|
||||
**Ziel:** DevExpress Services implementieren (wir sehen **echten** Code!)
|
||||
|
||||
---
|
||||
|
||||
#### ? Step 3.1: IPdfProcessor Interface erstellen
|
||||
#### ? Step 3.1: IPdfProcessor Interface erstellen - **COMPLETED**
|
||||
|
||||
**Aufgabe:** Abstraction für PDF-Operationen
|
||||
|
||||
**Was du erstellen wirst:**
|
||||
- **Wo:** `Application/Common/Interfaces/IPdfProcessor.cs`
|
||||
**Was du erstellt hast:**
|
||||
- **Wo:** `Application/Common/Interfaces/IPdfProcessor.cs` ?
|
||||
- **Inhalt:**
|
||||
```csharp
|
||||
using DocumentOperator.Domain.Models.ValueObjects;
|
||||
|
||||
namespace DocumentOperator.Application.Common.Interfaces;
|
||||
|
||||
public interface IPdfProcessor
|
||||
{
|
||||
Task<PdfMetadata> ValidateAsync(byte[] pdfBytes);
|
||||
// Weitere Methoden später (YAGNI!)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -863,9 +874,15 @@ DocumentOperator.Tests/
|
||||
- Infrastructure implementiert
|
||||
- TDD: Test ? Interface ? Implementation
|
||||
|
||||
**Status:** ? **COMPLETED** (17.01.2025)
|
||||
- ? Interface erstellt mit XML Comments
|
||||
- ? Using Statement korrekt
|
||||
- ? Namespace korrekt
|
||||
- ? Build erfolgreich
|
||||
|
||||
---
|
||||
|
||||
#### ? Step 3.2: DevExpressPdfProcessor implementieren (mit TDD!)
|
||||
#### ?? Step 3.2: DevExpressPdfProcessor implementieren (mit TDD!) - **NEXT**
|
||||
|
||||
**Aufgabe:** DevExpress Integration
|
||||
|
||||
@@ -1271,6 +1288,23 @@ public async Task POST_ValidatePdf_InvalidPdf_Returns400() { }
|
||||
## ?? CURRENT STATUS
|
||||
|
||||
### ? Completed
|
||||
- **Phase 1:** Foundation & Clean Architecture Setup ?
|
||||
- Dependencies ?
|
||||
- Packages ?
|
||||
- Folder Structure ?
|
||||
- Configuration ?
|
||||
- Serilog ?
|
||||
|
||||
- **Phase 2:** Domain Layer (Minimal) ?
|
||||
- ? Step 2.1 - Domain Exceptions (4 Exceptions erstellt)
|
||||
- ? Step 2.2 - Enums (DocumentOperationType, ProcessingStatus)
|
||||
- ? Step 2.3 - Value Objects (Base64String, TenantId, PdfMetadata)
|
||||
|
||||
### ?? In Progress
|
||||
- **Phase 3:** Infrastructure Layer (Outside-In!)
|
||||
- **NEXT:** Step 3.1 - IPdfProcessor Interface erstellen
|
||||
|
||||
### ? Pending
|
||||
- **Phase 1:** Foundation & Clean Architecture Setup
|
||||
- Dependencies ?
|
||||
- Packages ?
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using DocumentOperator.Domain.Models.ValueObjects;
|
||||
|
||||
namespace DocumentOperator.Application.Common.Interfaces;
|
||||
|
||||
public interface IPdfProcessor
|
||||
{
|
||||
/// <summary>
|
||||
/// Validates a PDF and extracts metadata.
|
||||
/// </summary>
|
||||
/// <param name="pdfBytes">PDF content as byte array</param>
|
||||
/// <returns>PDF metadata (page count, size, version, attachments)</returns>
|
||||
/// <exception cref="Domain.Common.Exceptions.PdfProcessingException">
|
||||
/// Thrown when PDF is corrupted or cannot be processed
|
||||
/// </exception>
|
||||
Task<PdfMetadata> ValidateAsync(byte[] pdfBytes);
|
||||
}
|
||||
@@ -17,7 +17,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Common\Interfaces\" />
|
||||
<Folder Include="Common\Behaviors\" />
|
||||
<Folder Include="Common\DTOs\" />
|
||||
<Folder Include="Common\Mappings\" />
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="Common\Results\" />
|
||||
<Folder Include="Constants\" />
|
||||
<Folder Include="Models\ValueObjects\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
59
DocumentOperator.Domain/Models/ValueObjects/Base64String.cs
Normal file
59
DocumentOperator.Domain/Models/ValueObjects/Base64String.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
namespace DocumentOperator.Domain.Models.ValueObjects;
|
||||
|
||||
public sealed class Base64String
|
||||
{
|
||||
public string Value { get; }
|
||||
|
||||
private Base64String(string value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public static Base64String Create(string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
throw new Common.Exceptions.DomainValidationException("Base64 string cannot be empty.");
|
||||
|
||||
// Validierung: Ist es gültiges Base64?
|
||||
try
|
||||
{
|
||||
Convert.FromBase64String(value);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
throw new Common.Exceptions.DomainValidationException("Invalid Base64 format.");
|
||||
}
|
||||
|
||||
return new Base64String(value);
|
||||
}
|
||||
|
||||
public static Base64String FromByteArray(byte[] bytes)
|
||||
{
|
||||
if (bytes == null || bytes.Length == 0)
|
||||
throw new Common.Exceptions.DomainValidationException("Byte array cannot be null or empty.");
|
||||
|
||||
var base64 = Convert.ToBase64String(bytes);
|
||||
return new Base64String(base64);
|
||||
}
|
||||
|
||||
public byte[] ToByteArray()
|
||||
{
|
||||
return Convert.FromBase64String(Value);
|
||||
}
|
||||
|
||||
public override string ToString() => Value;
|
||||
|
||||
// Equality (wichtig für Value Objects!)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is not Base64String other)
|
||||
return false;
|
||||
|
||||
return Value == other.Value;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Value.GetHashCode();
|
||||
}
|
||||
}
|
||||
32
DocumentOperator.Domain/Models/ValueObjects/PdfMetadata.cs
Normal file
32
DocumentOperator.Domain/Models/ValueObjects/PdfMetadata.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
namespace DocumentOperator.Domain.Models.ValueObjects;
|
||||
|
||||
public sealed class PdfMetadata
|
||||
{
|
||||
public int PageCount { get; }
|
||||
public long FileSizeBytes { get; }
|
||||
public string PdfVersion { get; }
|
||||
public bool HasAttachments { get; }
|
||||
public int AttachmentCount { get; }
|
||||
|
||||
// Computed Property (berechnet aus FileSizeBytes)
|
||||
public double FileSizeMB => FileSizeBytes / 1024.0 / 1024.0;
|
||||
|
||||
public PdfMetadata(
|
||||
int pageCount,
|
||||
long fileSizeBytes,
|
||||
string pdfVersion,
|
||||
bool hasAttachments,
|
||||
int attachmentCount)
|
||||
{
|
||||
PageCount = pageCount;
|
||||
FileSizeBytes = fileSizeBytes;
|
||||
PdfVersion = pdfVersion;
|
||||
HasAttachments = hasAttachments;
|
||||
AttachmentCount = attachmentCount;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"PDF: {PageCount} pages, {FileSizeMB:F2} MB, Version {PdfVersion}, Attachments: {AttachmentCount}";
|
||||
}
|
||||
}
|
||||
41
DocumentOperator.Domain/Models/ValueObjects/TenantId.cs
Normal file
41
DocumentOperator.Domain/Models/ValueObjects/TenantId.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
namespace DocumentOperator.Domain.Models.ValueObjects;
|
||||
|
||||
public sealed class TenantId
|
||||
{
|
||||
public string Value { get; }
|
||||
|
||||
private TenantId(string value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public static TenantId Create(string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
throw new Common.Exceptions.DomainValidationException("TenantId cannot be empty.");
|
||||
|
||||
if (value.Length > 100)
|
||||
throw new Common.Exceptions.DomainValidationException("TenantId cannot exceed 100 characters.");
|
||||
|
||||
// Normalisierung: Lowercase
|
||||
var normalized = value.Trim().ToLowerInvariant();
|
||||
|
||||
return new TenantId(normalized);
|
||||
}
|
||||
|
||||
public override string ToString() => Value;
|
||||
|
||||
// Equality
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is not TenantId other)
|
||||
return false;
|
||||
|
||||
return Value == other.Value;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Value.GetHashCode();
|
||||
}
|
||||
}
|
||||
34
DocumentOperator.Tests/DocumentOperator.Tests.csproj
Normal file
34
DocumentOperator.Tests/DocumentOperator.Tests.csproj
Normal file
@@ -0,0 +1,34 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="FluentAssertions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
|
||||
<PackageReference Include="Moq" Version="4.20.72" />
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DocumentOperator.Domain\DocumentOperator.Domain.csproj" />
|
||||
<ProjectReference Include="..\DocumentOperator.Application\DocumentOperator.Application.csproj" />
|
||||
<ProjectReference Include="..\DocumentOperator.Infrastructure\DocumentOperator.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
11
DocumentOperator.Tests/UnitTest1.cs
Normal file
11
DocumentOperator.Tests/UnitTest1.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace DocumentOperator.Tests
|
||||
{
|
||||
public class UnitTest1
|
||||
{
|
||||
[Fact]
|
||||
public void Test1()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocumentOperator.Infrastruc
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocumentOperator.Domain", "DocumentOperator.Domain\DocumentOperator.Domain.csproj", "{B4C1C3ED-D3E8-4272-8704-2E73CEA6A0DD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocumentOperator.Tests", "DocumentOperator.Tests\DocumentOperator.Tests.csproj", "{32D2E997-3DA7-4061-8A50-DBB34BBC3E5A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -33,6 +35,10 @@ Global
|
||||
{B4C1C3ED-D3E8-4272-8704-2E73CEA6A0DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B4C1C3ED-D3E8-4272-8704-2E73CEA6A0DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B4C1C3ED-D3E8-4272-8704-2E73CEA6A0DD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{32D2E997-3DA7-4061-8A50-DBB34BBC3E5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{32D2E997-3DA7-4061-8A50-DBB34BBC3E5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{32D2E997-3DA7-4061-8A50-DBB34BBC3E5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{32D2E997-3DA7-4061-8A50-DBB34BBC3E5A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user