umogen-ng/test/Nyanlabs.Umogen.CoreTests/NLSerializationTests.cs

68 lines
1.9 KiB
C#
Raw Normal View History

2023-11-17 21:33:38 +01:00
using Nyanlabs.Umogen.Core.Models;
namespace Nyanlabs.Umogen.CoreTests;
public class NLSerializationTests
{
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 void FullDocumentNLTest()
{
// Given
UmoDocument doc = new(UmoDoctype.CONTR_EMPLOYMENT, ModelEmployer, ModelEmployee);
// When
var query = doc.NLSerialize();
// Then
Assert.Equal($"Contract of Employment for {ModelEmployee.NLSerialize()} working for {ModelEmployer.NLSerialize()}; valid for unspecified time.", query);
}
[Fact]
public void FullDocumentNLTestSpecifiedTime()
{
// Given
UmoDocument doc = new(UmoDoctype.CONTR_EMPLOYMENT, ModelEmployer, ModelEmployee, new(new DateTime(2023, 11, 17), TimeSpan.FromDays(1)));
// When
var query = doc.NLSerialize();
// Then
Assert.Equal($"Contract of Employment for {ModelEmployee.NLSerialize()} working for {ModelEmployer.NLSerialize()}; valid from 17 Nov 2023 until 18 Nov 2023.", query);
}
[Fact]
public void PersonNLTest()
{
// Given
Person p = ModelEmployer;
// When
var query = p.NLSerialize();
// Then
Assert.Equal("Kotek Miauczyński; PESEL 04281308999; ID series CBS4327563; born 13 Aug 2004", query);
}
[Fact]
public void PersonNLTestNoData()
{
// Given
Person p = ModelEmployer with
{
IDCode = null,
Pesel = null,
DoB = null,
};
// When
var query = p.NLSerialize();
// Then
Assert.Equal("Kotek Miauczyński; unknown PESEL; unknown ID series; unknown date of birth", query);
}
}