Skip to content

Commit

Permalink
Fix: Update serializatoin tests so it doesn't rely on the hardcoded l…
Browse files Browse the repository at this point in the history
…ibrary version string
  • Loading branch information
kwokhe committed Jan 14, 2025
1 parent cac9965 commit 31135be
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Adyen.Test/SerializerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
using System.Collections.Generic;
using System.Text;
using Adyen.ApiSerialization;
using Adyen.Constants;
using Adyen.Model.Checkout;
using Adyen.Model.Terminal;
using Adyen.Model.TerminalApi;
using Adyen.Model.TerminalApi.Message;
using Adyen.Security;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using ApplicationInfo = Adyen.Model.ApplicationInformation.ApplicationInfo;
using CommonField = Adyen.Model.ApplicationInformation.CommonField;
using PaymentRequest = Adyen.Model.TerminalApi.PaymentRequest;
using PaymentResponse = Adyen.Model.TerminalApi.PaymentResponse;

Expand Down Expand Up @@ -191,8 +195,17 @@ private static string SerializeSaleToPoiMessageSecured(SaleToPOIMessage saleToPo
return saleToPoiMessageSerializer.Serialize(saleToPoiMessageSecured);
}

/// <summary>
/// Returns a POS Payment Request for our serialization tests.
/// Hardcode the version so that we can test the hardcoded hmac (after encryption) and SaleToAcquirerData:
/// <see cref="ExpectedSaleToPoiMessageJson"/> and <see cref="ExpectedSaleToPoiMessageSecuredJson"/> can be
/// <returns><see cref="SaleToPOIRequest"/>.</returns>
/// </summary>
private static SaleToPOIRequest CreatePosPaymentRequest()
{
ApplicationInfo aplicationInfo = new ApplicationInfo();
aplicationInfo.AdyenLibrary.Version = "26.1.0";

return new SaleToPOIRequest
{
MessageHeader = new MessageHeader
Expand All @@ -205,9 +218,13 @@ private static SaleToPOIRequest CreatePosPaymentRequest()
ServiceID = "12345678"
},
MessagePayload = new PaymentRequest
{
{
SaleData = new SaleData
{
SaleToAcquirerData = new SaleToAcquirerData()
{
ApplicationInfo = aplicationInfo
},
SaleTransactionID = new TransactionIdentification
{
TransactionID = "PosAuth",
Expand Down

0 comments on commit 31135be

Please sign in to comment.