Tests: Implement tests for Austrian Ebics
All checks were successful
Test / Run tests (push) Successful in 2m0s
All checks were successful
Test / Run tests (push) Successful in 2m0s
This commit is contained in:
@ -86,9 +86,9 @@ namespace Elwig.Helpers.Export {
|
|||||||
var full = ShowAddresses == AddressMode.Full;
|
var full = ShowAddresses == AddressMode.Full;
|
||||||
await Writer.WriteLineAsync($"""
|
await Writer.WriteLineAsync($"""
|
||||||
<PstlAdr>
|
<PstlAdr>
|
||||||
<Ctry>{a.PostalDest.Country.Alpha2}</Ctry>
|
|
||||||
{(full ? $"<StrtNm>{SecurityElement.Escape(a1?[..Math.Min(70, a1.Length)])}</StrtNm> <BldgNb>{SecurityElement.Escape(a2?[..Math.Min(16, a2.Length)])}</BldgNb>" : $"<AdrLine>{a.Address[..Math.Min(70, a.Address.Length)]}</AdrLine>")}
|
{(full ? $"<StrtNm>{SecurityElement.Escape(a1?[..Math.Min(70, a1.Length)])}</StrtNm> <BldgNb>{SecurityElement.Escape(a2?[..Math.Min(16, a2.Length)])}</BldgNb>" : $"<AdrLine>{a.Address[..Math.Min(70, a.Address.Length)]}</AdrLine>")}
|
||||||
<{(full ? "PstCd" : "AdrLine")}>{a.PostalDest.AtPlz?.Plz}{(full ? "</PstCd> <TwnNm>" : " ")}{SecurityElement.Escape(a.PostalDest.AtPlz?.Ort.Name)}</{(full ? "TwnNm" : "AdrLine")}>
|
<{(full ? "PstCd" : "AdrLine")}>{a.PostalDest.AtPlz?.Plz}{(full ? "</PstCd> <TwnNm>" : " ")}{SecurityElement.Escape(a.PostalDest.AtPlz?.Ort.Name)}</{(full ? "TwnNm" : "AdrLine")}>
|
||||||
|
<{(full ? "" : "!--")}Ctry>{a.PostalDest.Country.Alpha2}</Ctry{(full ? "" : "--")}>
|
||||||
</PstlAdr>
|
</PstlAdr>
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,16 @@ namespace Tests.HelperTests {
|
|||||||
public static readonly string FileName = Path.Combine(Path.GetTempPath(), "test_ebics.xml");
|
public static readonly string FileName = Path.Combine(Path.GetTempPath(), "test_ebics.xml");
|
||||||
public static readonly string Iban = "AT123456789012345678";
|
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();
|
XmlDocument xml = new();
|
||||||
xml.Load(xmlPath);
|
xml.Load(xmlPath);
|
||||||
var schema = new XmlTextReader(Assembly.GetExecutingAssembly()
|
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.Schemas.Add(null, schema);
|
||||||
xml.Validate(null);
|
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() {
|
var v = new PaymentVar() {
|
||||||
Year = 2020,
|
Year = 2020,
|
||||||
AvNr = 1,
|
AvNr = 1,
|
||||||
@ -35,7 +35,7 @@ namespace Tests.HelperTests {
|
|||||||
using var ctx = new AppDbContext();
|
using var ctx = new AppDbContext();
|
||||||
var members = ctx.Members.ToList();
|
var members = ctx.Members.ToList();
|
||||||
Assert.That(members, Has.Count.GreaterThan(0));
|
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)));
|
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));
|
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]
|
[Test]
|
||||||
public async Task Test_CustomerCreditTransferInitiationV04() {
|
public async Task Test_CustomerCreditTransferInitiationV04() {
|
||||||
await CreateXmlFile(4);
|
await CreateXmlFile(4);
|
||||||
|
1340
Tests/Resources/Schemas/pain.001.001.03.AT.xsd
Normal file
1340
Tests/Resources/Schemas/pain.001.001.03.AT.xsd
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user