43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using System.Text;
|
|
using System.Text.Json;
|
|
|
|
using Nyanlabs.Umogen.Core;
|
|
using Nyanlabs.Umogen.Core.Models;
|
|
|
|
namespace Nyanlabs.Umogen.CoreTests;
|
|
|
|
public class PdfTest
|
|
{
|
|
|
|
private Person ModelEmployer => new("Kotek", "Miauczyński", "CBS4327563", "04281308999", new DateTime(2004, 08, 13));
|
|
|
|
private Person ModelEmployee => new("Miau", "Kotczyński", "CBS69696969", "76011694336", new DateTime(1976, 1, 16));
|
|
|
|
[Fact]
|
|
public async void RenderBoi()
|
|
{
|
|
// Given
|
|
string root = Environment.CurrentDirectory.Replace("test/Nyanlabs.Umogen.WebTests/bin/Debug/net8.0", "");
|
|
UmoEngine eng = new(Path.Combine(root, Core.Umogen.DEFAULT_API_KEY_FILE));
|
|
|
|
UmoProcess p = new(eng);
|
|
|
|
StringBuilder sb = new();
|
|
|
|
await foreach (var str in p.Ask($"Zatrudnij {ModelEmployee.NLQuerySerialize()} jako programistę z wynagrodzeniem 12137zł."))
|
|
{
|
|
Console.Write(str);
|
|
sb.Append(str);
|
|
}
|
|
|
|
var anal = JsonSerializer.Deserialize<UmoAnalModel>(sb.ToString(), Core.Umogen.JSON_OPTS);
|
|
UmoDocumentResult r = new(null, ModelEmployer, ModelEmployee, ValidTime.Invalid, 2137, anal);
|
|
|
|
// When
|
|
byte[] b = await r.ProcessPdf(Path.Combine(root, $"templates/{r.DocType.TemplateDoc()}"));
|
|
// Then
|
|
|
|
await File.WriteAllBytesAsync(Path.Combine(root, "out.pdf"), b);
|
|
|
|
}
|
|
}
|