2023-11-18 05:59:32 +01:00
|
|
|
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);
|
2023-11-18 16:31:51 +01:00
|
|
|
UmoDocumentResult r = new(null, ModelEmployer, ModelEmployee, ValidTime.Invalid, 2137, anal!);
|
2023-11-18 05:59:32 +01:00
|
|
|
|
|
|
|
// When
|
|
|
|
byte[] b = await r.ProcessPdf(Path.Combine(root, $"templates/{r.DocType.TemplateDoc()}"));
|
|
|
|
// Then
|
|
|
|
|
|
|
|
await File.WriteAllBytesAsync(Path.Combine(root, "out.pdf"), b);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|