Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix date and time data types #7

Merged
merged 6 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,19 @@ jobs:
run: dotnet build --configuration Release --no-restore

- name: Run Unit Tests
run: dotnet test -p:CollectCoverage=true -p:CoverletOutput=TestResults/ -p:CoverletOutputFormat=opencover --configuration Release --no-build --verbosity normal
run: >
dotnet test
-p:CollectCoverage=true
-p:CoverletOutput=TestResults/
-p:CoverletOutputFormat=opencover
--configuration Release
--no-build
--verbosity normal

- name: ReSharper annotations
uses: VMelnalksnis/[email protected]
with:
solution: VMelnalksnis.ISO20022DotNet.sln

- name: Gather Code Coverage
uses: codecov/codecov-action@v2
Expand Down
12 changes: 12 additions & 0 deletions VMelnalksnis.ISO20022DotNet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VMelnalksnis.ISO20022DotNet.Tests", "tests\VMelnalksnis.ISO20022DotNet.Tests\VMelnalksnis.ISO20022DotNet.Tests.csproj", "{D2CD56EB-494B-4A1F-820A-5FBC73E70491}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{D744ADD7-E267-45F2-A5F8-E49F05BBEDBE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{E4EDD697-399B-4683-8DB9-B8DC2D6E2B0B}"
ProjectSection(SolutionItems) = preProject
.github\workflows\build-and-publish.yml = .github\workflows\build-and-publish.yml
.github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -29,4 +37,8 @@ Global
{D2CD56EB-494B-4A1F-820A-5FBC73E70491}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2CD56EB-494B-4A1F-820A-5FBC73E70491}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{D744ADD7-E267-45F2-A5F8-E49F05BBEDBE} = {760EA339-4B69-41E1-88EC-510992A1E56F}
{E4EDD697-399B-4683-8DB9-B8DC2D6E2B0B} = {D744ADD7-E267-45F2-A5F8-E49F05BBEDBE}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public sealed record AccountReport11
/// </summary>
[Required]
[XmlElement("CreDtTm")]
public Instant CreationDateTime { get; init; }
public LocalDateTime CreationDateTime { get; init; }

/// <summary>
/// Gets range of time between a start date and an end date for which the account report is issued.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public sealed record DateTimePeriodDetails
{
[Required]
[XmlElement("FrDtTm")]
public Instant FrDtTm { get; init; }
public LocalDateTime FrDtTm { get; init; }

[Required]
[XmlElement("ToDtTm")]
public Instant ToDtTm { get; init; }
public LocalDateTime ToDtTm { get; init; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public sealed record GroupHeader42
/// </summary>
[Required]
[XmlElement("CreDtTm")]
public Instant CreationDateTime { get; init; }
public LocalDateTime CreationDateTime { get; init; }

/// <summary>
/// Gets party authorised by the account owner to receive information about movements on the account.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<Major>0</Major>
<Minor>2</Minor>
<Revision>0</Revision>
<Revision>1</Revision>

<BuildNumber Condition=" '$(BuildNumber)' == '' ">0</BuildNumber>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
Expand All @@ -35,7 +37,7 @@ public class AccountReportDocumentTests
[Test]
public void ReadActualDocument()
{
var creationInstant = Instant.FromUtc(2001, 12, 17, 09, 30, 47);
var dateTime = new LocalDateTime(2001, 12, 17, 09, 30, 47);
var date = new LocalDate(2001, 12, 17);

var expectedDocument = new Document
Expand All @@ -45,18 +47,18 @@ public void ReadActualDocument()
GroupHeader = new()
{
MessageIdentification = "STMT20130710193521",
CreationDateTime = creationInstant,
CreationDateTime = dateTime,
},
Reports =
{
new AccountReport11
{
Identification = "5074322222537",
CreationDateTime = creationInstant,
CreationDateTime = dateTime,
FromToDate = new()
{
FrDtTm = creationInstant,
ToDtTm = creationInstant,
FrDtTm = dateTime,
ToDtTm = dateTime,
},
Account = new()
{
Expand Down Expand Up @@ -195,13 +197,8 @@ public void ReadActualDocument()
},
};

var directory = Path.Combine(
TestContext.CurrentContext.TestDirectory,
"MessageSets/BankToCustomerCashManagement/V2/AccountReport/");

var schemaFilePath = Path.Combine(directory, "camt.052.001.02.xsd");
var schemas = new XmlSchemaSet();
using var schemaStream = File.OpenRead(schemaFilePath);
using var schemaStream = ReadEmbeddedResource("camt.052.001.02.xsd");
var schemaXmlReader = XmlReader.Create(schemaStream);
schemas.Add("urn:iso:std:iso:20022:tech:xsd:camt.052.001.02", schemaXmlReader);

Expand All @@ -227,8 +224,7 @@ public void ReadActualDocument()
Console.WriteLine(args.Exception.ToString());
};

var dataFilePath = Path.Combine(directory, "BankToCustomerAccountReportV02.xml");
using var stream = File.OpenRead(dataFilePath);
using var stream = ReadEmbeddedResource("BankToCustomerAccountReportV02.xml");
using var xmlReader = XmlReader.Create(stream, xmlSettings);
var serializer = new XmlSerializer(typeof(Document));
var document = (Document)serializer.Deserialize(xmlReader)!;
Expand All @@ -240,6 +236,17 @@ public void ReadActualDocument()
}
}

private static Stream ReadEmbeddedResource(string resource)
{
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(AccountReportDocumentTests), resource);
if (stream is null)
{
throw new MissingManifestResourceException();
}

return stream;
}

private static EquivalencyAssertionOptions<Document> Config(EquivalencyAssertionOptions<Document> options)
{
return options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<BkToCstmrAcctRpt>
<GrpHdr>
<MsgId>STMT20130710193521</MsgId>
<CreDtTm>2001-12-17T09:30:47Z</CreDtTm>
<CreDtTm>2001-12-17T09:30:47</CreDtTm>
</GrpHdr>
<Rpt>
<Id>5074322222537</Id>
<CreDtTm>2001-12-17T09:30:47Z</CreDtTm>
<CreDtTm>2001-12-17T09:30:47</CreDtTm>
<FrToDt>
<FrDtTm>2001-12-17T09:30:47Z</FrDtTm>
<ToDtTm>2001-12-17T09:30:47Z</ToDtTm>
<FrDtTm>2001-12-17T09:30:47</FrDtTm>
<ToDtTm>2001-12-17T09:30:47</ToDtTm>
</FrToDt>
<Acct>
<Id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,8 @@
</ItemGroup>

<ItemGroup>
<None Update="Messages\BankToCustomerCashManagement\V2\AccountReport\BankToCustomerAccountReportV02.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Messages\BankToCustomerCashManagement\V2\AccountReport\camt.052.001.02.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="MessageSets\BankToCustomerCashManagement\V2\AccountReport\camt.052.001.02.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="MessageSets\BankToCustomerCashManagement\V2\AccountReport\BankToCustomerAccountReportV02.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<EmbeddedResource Include="MessageSets\BankToCustomerCashManagement\V2\AccountReport\camt.052.001.02.xsd"/>
<EmbeddedResource Include="MessageSets\BankToCustomerCashManagement\V2\AccountReport\BankToCustomerAccountReportV02.xml"/>
</ItemGroup>

</Project>