admin/src/Oms.Tests/Labeling/QuestPdfLabelRendererTests.cs
zzh b679151eb1 feat: Hiprint模板转QuestPDF异步出面单,并接通打印链路
支持模板预览/字段字典、产品绑定 LabelTemplateId、订单 Pending→Ready 生成 PDF,以及 order/print、批量与仓内 printUrl。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-18 14:52:39 +08:00

30 lines
937 B
C#

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<string, object?>
{
["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);
}
}