test(nuget): add NuGet smoke-test console app (DocumentService.Tests.NuGet)

Standalone console application that references the published DocumentService.Client
NuGet package (v1.2.2) and verifies the full happy-path against a live API instance.

- Targets net8.0; references DocumentService.Client 1.2.2 via NuGet (not project ref)
- Embeds valid.pdf as an EmbeddedResource so no file-system path is required
- Calls Client.Validation.ValidateAsync(Stream) and prints PageCount, PdfVersion,
  IsEncrypted, AttachmentCount, FileSizeBytes to stdout
- Handles HttpRequestException and InvalidOperationException with descriptive output
- Intended to run once after a new package is pushed to confirm the .nupkg bundles
  Application and Domain DLLs correctly (validates the embedding targets added in
  the previous commit)
This commit is contained in:
2026-09-21 10:10:09 +02:00
parent 24db1b0d0a
commit 6527cdcbb0
3 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="valid.pdf" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DocumentService.Client" Version="1.2.2" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,36 @@
using DocumentService.Client;
// 1. Configure the client
Client.Configure("http://172.24.12.39:9393/");
// 2. Load embedded PDF resource
var assembly = typeof(Program).Assembly;
var resourceName = assembly.GetManifestResourceNames()
.FirstOrDefault(n => n.EndsWith("valid.pdf", StringComparison.OrdinalIgnoreCase));
if (resourceName is null)
{
Console.WriteLine("❌ Embedded resource 'valid.pdf' not found.");
return;
}
try
{
using var stream = assembly.GetManifestResourceStream(resourceName)!;
var result = await Client.Validation.ValidateAsync(stream);
Console.WriteLine("✅ Connection successful!");
Console.WriteLine($" Page count : {result.PageCount}");
Console.WriteLine($" PDF version : {result.PdfVersion}");
Console.WriteLine($" Encrypted : {result.IsEncrypted}");
Console.WriteLine($" Attachments : {result.AttachmentCount}");
Console.WriteLine($" File size : {result.FileSizeMB:F2} MB");
}
catch (HttpRequestException ex)
{
Console.WriteLine("❌ HTTP error: " + ex.Message);
}
catch (InvalidOperationException ex)
{
Console.WriteLine("❌ Client error: " + ex.Message);
}

Binary file not shown.