Skip to content

Commit

Permalink
Fixed serialization when serializing from BaseRequestBody
Browse files Browse the repository at this point in the history
  • Loading branch information
zvizdo committed Mar 22, 2016
1 parent da200fb commit abfa109
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 7 deletions.
45 changes: 45 additions & 0 deletions src/MadWare.Furs.UnitTest/TestDigitalSignatureProviders.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using MadWare.Furs.Encryption;
using MadWare.Furs.Requests;
using MadWare.Furs.Serialization;
using MadWare.Furs.ZOI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;

namespace MadWare.Furs.UnitTest
{
public class TestDigitalSignatureProviders
{

public static IEnumerable<object[]> TestDataCalculateSigInvoice()
{
return new[] {
new object[] {
new Envelope<BaseRequestBody> { Body = new InvoiceRequestBody { InvoiceRequest = new Models.Invoice.InvoiceRequest {
Invoice = new Models.Invoice.Invoice {
TaxNumber = "12345678",
IssueDateTime = new DateTime(2016, 3, 20, 20, 0, 0),
InvoiceIdentifier = new Models.Invoice.InvoiceIdentifier { BusinessPremiseID = "PP1", ElectronicDeviceID = "EN1", InvoiceNumber = "123" },
InvoiceAmount = 12.34M
} } } }
}
};
}

[Theory]
[MemberData("TestDataCalculateSigInvoice")]
public void TestDigitalSignatureXmlInvoice<T>(Envelope<BaseRequestBody> e)
{
IEnvelopeSerializer s = new XmlEnvelopeSerializer();
string payload = s.SerializeEnvelope(e);

var cert = new System.Security.Cryptography.X509Certificates.X509Certificate2(@"E:\Programiranje\MadWare.Furs\src\MadWare.Furs.UnitTest\10442529-1.p12", "SAMR6ADL8IE6");
IDigitalSignatureProvider sig = new CertXmlDigitalSignatureProvider(cert);

string signedPayload = sig.Sign(payload, e);
}

}
}
2 changes: 1 addition & 1 deletion src/MadWare.Furs.UnitTest/TestXmlSerialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void TestBusinessPremiseSerialize()
}
};

var e = new Envelope<BusinessPremiseRequestBody> { Body = bp };
var e = new Envelope<BaseRequestBody> { Body = bp };

string xml = s.SerializeEnvelope(e);
}
Expand Down
6 changes: 0 additions & 6 deletions src/MadWare.Furs.UnitTest/TestZOICalculation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ namespace MadWare.Furs.UnitTest
public class TestZOICalculation
{

public class MustCalculateZOIHolder
{
public Envelope<BaseRequestBody> e { get; set; }
public bool doCalc { get; set; }
}

public static IEnumerable<object[]> TestDataMustCalculateZOI()
{
return new[] {
Expand Down
4 changes: 4 additions & 0 deletions src/MadWare.Furs/Serialization/Envelope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public class Envelope<T> where T : BaseRequestBody
public T Body { get; set; }
}

[XmlInclude(typeof(Requests.EchoRequestBody))]
[XmlInclude(typeof(Requests.BusinessPremiseRequestBody))]
[XmlInclude(typeof(Requests.InvoiceRequestBody))]
[XmlRoot(Namespace = "http://www.fu.gov.si/")]
public abstract class BaseRequestBody
{
/// <summary>
Expand Down

0 comments on commit abfa109

Please sign in to comment.