Tests: Implement tests for Austrian Ebics
All checks were successful
Test / Run tests (push) Successful in 2m0s

This commit is contained in:
2024-06-13 01:43:23 +02:00
parent b404839ad1
commit 46551fb142
3 changed files with 1351 additions and 5 deletions

View File

@ -14,16 +14,16 @@ namespace Tests.HelperTests {
public static readonly string FileName = Path.Combine(Path.GetTempPath(), "test_ebics.xml");
public static readonly string Iban = "AT123456789012345678";
private static void ValidateSchema(string xmlPath, int version) {
private static void ValidateSchema(string xmlPath, int version, string? extra = null) {
XmlDocument xml = new();
xml.Load(xmlPath);
var schema = new XmlTextReader(Assembly.GetExecutingAssembly()
.GetManifestResourceStream($"Tests.Resources.Schemas.pain.001.001.{version:00}.xsd")!);
.GetManifestResourceStream($"Tests.Resources.Schemas.pain.001.001.{version:00}{extra}.xsd")!);
xml.Schemas.Add(null, schema);
xml.Validate(null);
}
private static async Task CreateXmlFile(int version) {
private static async Task CreateXmlFile(int version, Ebics.AddressMode mode = Ebics.AddressMode.Full) {
var v = new PaymentVar() {
Year = 2020,
AvNr = 1,
@ -35,7 +35,7 @@ namespace Tests.HelperTests {
using var ctx = new AppDbContext();
var members = ctx.Members.ToList();
Assert.That(members, Has.Count.GreaterThan(0));
using var exporter = new Ebics(v, FileName, version);
using var exporter = new Ebics(v, FileName, version, mode);
await exporter.ExportAsync(members.Select(m => new Transaction(m, 1234.56m, "EUR", m.MgNr % 100)));
}
@ -64,6 +64,12 @@ namespace Tests.HelperTests {
Assert.DoesNotThrow(() => ValidateSchema(FileName, 3));
}
[Test]
public async Task Test_CustomerCreditTransferInitiationV03_AT() {
await CreateXmlFile(3, Ebics.AddressMode.Lines);
Assert.DoesNotThrow(() => ValidateSchema(FileName, 3, ".AT"));
}
[Test]
public async Task Test_CustomerCreditTransferInitiationV04() {
await CreateXmlFile(4);