-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add batuz dtos #218
Add batuz dtos #218
Conversation
…n integration. Adding Dtos for invoice request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there a way to split this PR into multiple smaller PRs?
reviewing 14k lines of code at once is not a good idea.
using FuncSharp; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused usings
private const string BatuzXsdFilename = @"./Xsd/LROE_PJ_240_1_1_FacturasEmitidas_ConSG_AltaPeticion_V1_0_2.xsd"; | ||
private const string BatuzTiposComplejosFilename = @"./Xsd/batuz_TiposComplejos.xsd"; | ||
private const string BatuzEnumeradosFilename = @"./Xsd/batuz_Enumerados.xsd"; | ||
private const string BatuzTiposBasicosFilename = @"./Xsd/batuz_TiposBasicos.xsd"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant verbatim string prefix
public void CreateTBatuzInvoiceDto_XmlSerialization_Succeeds() | ||
{ | ||
//Arrange create a dto that matches the samples provided by the Bizkaia authorities | ||
var batuzInvoiceRequest = BatuzInvoiceRequestHelper.CreateSampleBatuzRequest(); | ||
|
||
//act check that xml serialization of the ticketBai succeeds without errors | ||
bool serializationSucceeds = XmlSerializationSucceeds(batuzInvoiceRequest, out XmlElement xmlElement); | ||
|
||
//assert that xml serialization was possible | ||
Assert.True(serializationSucceeds); | ||
Assert.NotNull(xmlElement); | ||
} | ||
|
||
[Test] | ||
public void CreateTicketBaiInvoice_XsdValidation_Succeeds() | ||
{ | ||
//Arrange create a dto that matches the samples provided by the Bizkaia authorities | ||
var batuzInvoiceRequest = BatuzInvoiceRequestHelper.CreateSampleBatuzRequest(); | ||
var schemas = new Dictionary<string, string> | ||
{ | ||
{"https://www.batuz.eus/fitxategiak/batuz/LROE/esquemas/LROE_PJ_240_1_1_FacturasEmitidas_ConSG_AltaPeticion_V1_0_2.xsd", BatuzXsdFilename }, | ||
{"https://www.batuz.eus/fitxategiak/batuz/LROE/esquemas/batuz_TiposComplejos.xsd", BatuzTiposComplejosFilename }, | ||
{"https://www.batuz.eus/fitxategiak/batuz/LROE/esquemas/batuz_Enumerados.xsd", BatuzEnumeradosFilename }, | ||
{"https://www.batuz.eus/fitxategiak/batuz/LROE/esquemas/batuz_TiposBasicos.xsd", BatuzTiposBasicosFilename } | ||
}; | ||
|
||
//act check that xml serialization of the ticketBai succeeds without errors | ||
bool serializationSucceeds = XmlSerializationSucceeds(batuzInvoiceRequest, out XmlElement xmlElement); | ||
//assert that xml serialization was possible | ||
Assert.True(serializationSucceeds); | ||
|
||
bool xsdValidationSucceeds = XmlSchemaHelper.XmlSchemaValidationSucceeds(element: xmlElement, | ||
validatingXsdFilename: BatuzXsdFilename, schemas); | ||
Assert.True(xsdValidationSucceeds); | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of these tests? wouldn't these test cases get covered later on when you create tests for sending an invoice? (like the other fiscalizations)?
and how frequently does these XSDs change? its just once when you import them, and if there will be an update one day, you will just import the new one and verify that your solution works using the other tests (like send_invoice_succeeds..etc)
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection.Metadata.Ecma335; | ||
using System.Text; | ||
using System.Threading.Tasks; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused usings
using System; | ||
using System.Collections.Generic; | ||
using System.Security; | ||
using System.Xml.Serialization; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused usings
private const string CorrectResponseFilename = @"./Documents/LROE_240_FacturasEmitidasConSG_Correcta.xml"; | ||
private const string PartiallyCorrectResponseFilename = @"./Documents/LROE_240_FacturasEmitidasConSG_Parc_Correcta.xml"; | ||
private const string IncorrectResponseFilename = @"./Documents/LROE_240_FacturasEmitidasConSG_Incorrecta.xml"; | ||
private const string TicketBaiFilename = @"./Documents/ticketBai.xml"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant verbatim string prefix
private bool XmlSerializationSucceeds(LROEPJ240FacturasEmitidasConSGAltaPeticion batuzInvoiceRequest, out XmlElement? xmlElement) | ||
{ | ||
try | ||
{ | ||
xmlElement = XmlSerializationHelper<LROEPJ240FacturasEmitidasConSGAltaPeticion>.Serialize(batuzInvoiceRequest, Array.Empty<string>()); | ||
return true; | ||
} | ||
catch | ||
{ | ||
xmlElement = null; | ||
return false; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of all this, can't you just use Assert.DoesNotThrow
?
|
||
namespace Mews.Fiscalizations.Bizkaia.Tests | ||
{ | ||
public static class XmlSerializationHelper<T> where T: class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the Xml helpers in the Core library?
[Test] | ||
public void CreateTicketBaiInvoice_XsdValidation_Succeeds() | ||
{ | ||
//Arrange create a dto that matches the samples provided by the Bizkaia authorities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't really add the AAA comments for every single test
Description
Implemented DTOS for the Batuz integration. Includes a preliminary version of the Models which will be improved in the future. Basic unit tests have been included to test: Dto serialization and deserialization (when applicable) and XSD validation.
Fixes https://mews.atlassian.net/browse/OPS-1744
Type of change
Checklist
Test cases: DTO serialization and deserialization, XSD validation after serializing.