using System.Text; using FluentAssertions; using Oms.Application.Labeling.Hiprint; namespace Oms.Tests.Labeling; public class QuestPdfLabelRendererTests { [Fact] public async Task RenderAsync_SampleTemplate_ShouldProducePdfBytes() { var json = HiprintTemplateParserTests.LoadFixture("sample_100x150.json"); var printData = new Dictionary { ["serviceNo"] = "S202607180001", ["recipientName"] = "John Lee", ["recipientAddressFull"] = "xxx Street, City, CA 90001", ["actualWeight"] = 1.25 }; var renderer = new QuestPdfLabelRenderer(new HiprintTemplateParser()); var bytes = await renderer.RenderAsync(json, printData); bytes.Should().NotBeNullOrEmpty(); // %PDF Encoding.ASCII.GetString(bytes.AsSpan(0, 4)).Should().Be("%PDF"); bytes.Length.Should().BeGreaterThan(500); } [Fact] public async Task RenderManyAsync_TwoPages_ShouldProducePdfBytes() { var json = HiprintTemplateParserTests.LoadFixture("sample_100x150.json"); var pages = new List> { new Dictionary { ["serviceNo"] = "S1", ["recipientName"] = "A", ["recipientAddressFull"] = "Addr A", ["actualWeight"] = 1 }, new Dictionary { ["serviceNo"] = "S2", ["recipientName"] = "B", ["recipientAddressFull"] = "Addr B", ["actualWeight"] = 2 } }; var renderer = new QuestPdfLabelRenderer(new HiprintTemplateParser()); var bytes = await renderer.RenderManyAsync(json, pages); bytes.Should().NotBeNullOrEmpty(); Encoding.ASCII.GetString(bytes.AsSpan(0, 4)).Should().Be("%PDF"); bytes.Length.Should().BeGreaterThan(800); } }