Files
DocumentService/DocumentService.Tests.NuGet/Program.cs
TekH 6527cdcbb0 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)
2026-09-21 10:10:09 +02:00

36 lines
1.1 KiB
C#

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);
}