Skip to content

Commit

Permalink
Fixed an issue when serializing bizkaia header mode (#226)
Browse files Browse the repository at this point in the history
* Fixed an issue serialzing bizkaia header mode

* Fixed GH actions

---------

Co-authored-by: abdallahbeshi <[email protected]>
  • Loading branch information
abdallahbeshi and abdallahbeshi authored Oct 25, 2023
1 parent 76e3780 commit 67f721a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 24 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/pr-automation-tech-be-assign.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Assign tech.be project
name: pr-automation
on:
pull_request:
types: [opened]
Expand All @@ -9,8 +9,9 @@ jobs:
assign-be-project:
runs-on: ubuntu-latest
steps:
- name: Assign tech.be project
uses: srggrs/[email protected]
- name: Assign to project
uses: srggrs/[email protected]
if: github.event.action == 'opened'
with:
project: 'https://github.com/orgs/MewsSystems/projects/3'
column_name: 'Review level 1'
column_name: 'Review'
7 changes: 4 additions & 3 deletions .github/workflows/pr-automation-tech-review-qa-assign.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Assign tech.qa.review project
name: pr-automation-qa-assign
on:
pull_request:
types: [opened]
Expand All @@ -9,8 +9,9 @@ jobs:
assign-qa-project:
runs-on: ubuntu-latest
steps:
- name: Assign tech.qa.review project
uses: srggrs/[email protected]
- name: Assign QA project
uses: srggrs/[email protected]
if: github.event.action == 'opened'
with:
project: 'https://github.com/orgs/MewsSystems/projects/5'
column_name: 'Waiting'
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Move to ready to test in tech.review.qa board
name: pr-automation-qa-move-on-close
on:
pull_request:
types: [closed]
jobs:
move-to-ready-to-test:
runs-on: ubuntu-latest
steps:
- name: Move to ready to test in tech.review.qa board
- name: Move to ready to test
uses: alex-page/[email protected]
with:
project: tech.review.qa
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Mews.Fiscalizations.Basque.Dto.Bizkaia.Header;
using Newtonsoft.Json;
using System.Text.Json;

namespace Mews.Fiscalizations.Basque.Tests.Bizkaia;

Expand All @@ -17,18 +17,35 @@ public class BizkaiaDataValidationTests
},
FiscalData = new FiscalData
{
Mode = Mode.Item240,
FiscalYear = 2022
}
};

private const string ExpectedSerializationResult = "{\"con\":\"LROE\",\"apa\":\"1.1\",\"inte\":{\"nif\":\"NIF\",\"nrs\":\"Name\",\"ap1\":\"Family name 1\",\"ap2\":\"Family name 2\"},\"drs\":{\"mode\":\"240\",\"ejer\":2022}}";

[Test]
public void Create_BizkaiaData_JsonSerialization_Succeeds()
{
Assert.DoesNotThrow(() =>
{
var serializedData = JsonConvert.SerializeObject(SampleBizkaiData);
var serializedData = JsonSerializer.Serialize(SampleBizkaiData);
File.WriteAllText("tmp.json", serializedData);
Assert.IsNotEmpty(serializedData);
Assert.AreEqual(serializedData, ExpectedSerializationResult);
});
}

[Test]
public void Create_BizkaiaData_Json_Serialization_Deserialization_Succeeds()
{
Assert.DoesNotThrow(() =>
{
var serializedData = JsonSerializer.Serialize(SampleBizkaiData);
Assert.IsNotEmpty(serializedData);
var deserializedData = JsonSerializer.Deserialize<BizkaiaHeaderData>(serializedData);
Assert.AreEqual(serializedData, JsonSerializer.Serialize(deserializedData));
});
}

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using System.Runtime.Serialization;


using System.Text.Json.Serialization;

namespace Mews.Fiscalizations.Basque.Dto.Bizkaia.Header;

public sealed class BizkaiaHeaderData
{
[JsonPropertyName("con")]
public static string HeaderType => "LROE";
public string HeaderType => "LROE";

[JsonPropertyName("apa")]
public static string Section => "1.1";
public string Section => "1.1";

[JsonPropertyName("inte")]
public IssuerData Issuer { get; set; }
Expand All @@ -21,7 +22,7 @@ public sealed class BizkaiaHeaderData
public sealed class FiscalData
{
[JsonPropertyName("mode")]
public Mode Mode { get; set; }
public string Mode => "240";

[JsonPropertyName("ejer")]
public int FiscalYear { get; set; }
Expand All @@ -41,11 +42,3 @@ public sealed class IssuerData
[JsonPropertyName("ap2")]
public string SecondSurname { get; set; }
}

public enum Mode
{
[EnumMember(Value = "140")]
Item140,
[EnumMember(Value = "240")]
Item240
}

0 comments on commit 67f721a

Please sign in to comment.