-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nayan Kumar S
committed
Oct 18, 2023
1 parent
c287d1b
commit 92c1075
Showing
31 changed files
with
1,124 additions
and
51 deletions.
There are no files selected for viewing
132 changes: 132 additions & 0 deletions
132
Amazon.Pay.API.SDK.Tests/WebStore/AccountManagement/RegisterAmazonPayAccountRequestTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
using Amazon.Pay.API.WebStore.AccountManagement; | ||
using Amazon.Pay.API.WebStore.Types; | ||
using NUnit.Framework; | ||
|
||
namespace Amazon.Pay.API.Tests.WebStore.AccountManagement | ||
{ | ||
[TestFixture] | ||
public class RegisterAmazonPayAccountRequestTests | ||
{ | ||
[Test] | ||
public void CanConstructWithAllPropertiesInitialized() | ||
{ | ||
// act | ||
var request = new RegisterAmazonPayAccountRequest(uniqueReferenceId: "ABCDEF1234", ledgerCurrency: LedgerCurrency.JPY); | ||
|
||
// assert | ||
Assert.IsNotNull(request); | ||
Assert.IsNotNull(request.BusinessInfo); | ||
Assert.IsNotNull(request.PrimaryContactPerson); | ||
} | ||
|
||
private RegisterAmazonPayAccountRequest CreateIndividualAccountRequest() | ||
{ | ||
var request = new RegisterAmazonPayAccountRequest(uniqueReferenceId: "ABCDEF12345", ledgerCurrency: LedgerCurrency.JPY) | ||
{ | ||
BusinessInfo = { | ||
BusinessType = BusinessType.INDIVIDUAL, | ||
CountryOfEstablishment = "JP", | ||
BusinessLegalName = "TestingSubmerchant", | ||
BusinessAddress = { | ||
AddressLine1 = "450", | ||
AddressLine2 = "Noda", | ||
City = "香取市", | ||
StateOrRegion = "千葉県", | ||
PostalCode = "289-0314", | ||
CountryCode = "JP" | ||
} | ||
} | ||
}; | ||
return request; | ||
} | ||
|
||
private RegisterAmazonPayAccountRequest CreateCorporateAccountRequest() | ||
{ | ||
var request = new RegisterAmazonPayAccountRequest(uniqueReferenceId: "ABCDEF12345", ledgerCurrency: LedgerCurrency.JPY) | ||
{ | ||
BusinessInfo = { | ||
BusinessType = BusinessType.CORPORATE, | ||
CountryOfEstablishment = "JP", | ||
BusinessLegalName = "TestingSubmerchant", | ||
BusinessAddress = { | ||
AddressLine1 = "450", | ||
AddressLine2 = "Noda", | ||
City = "香取市", | ||
StateOrRegion = "千葉県", | ||
PostalCode = "289-0314", | ||
CountryCode = "JP" | ||
} | ||
} | ||
}; | ||
return request; | ||
} | ||
|
||
private RegisterAmazonPayAccountRequest CreateCorporateAccountRequestWithPoc() | ||
{ | ||
var request = CreateCorporateAccountRequest(); | ||
request.PrimaryContactPerson.PersonFullName = "Testing"; | ||
request.PrimaryContactPerson.ResidentialAddress.AddressLine1 = "621-4"; | ||
request.PrimaryContactPerson.ResidentialAddress.AddressLine2 = "Haramanda"; | ||
request.PrimaryContactPerson.ResidentialAddress.City = "Arao City"; | ||
request.PrimaryContactPerson.ResidentialAddress.StateOrRegion = "Kumamoto"; | ||
request.PrimaryContactPerson.ResidentialAddress.PostalCode = "836-0806"; | ||
request.PrimaryContactPerson.ResidentialAddress.CountryCode = "JP"; | ||
return request; | ||
} | ||
|
||
[Test] | ||
public void CanConvertToJsonMinimal() | ||
{ | ||
// arrange | ||
var request = new RegisterAmazonPayAccountRequest(uniqueReferenceId: "ABCDEF1234", ledgerCurrency: LedgerCurrency.JPY); | ||
|
||
// act | ||
string json = request.ToJson(); | ||
|
||
// assert | ||
Assert.AreEqual("{\"uniqueReferenceId\":\"ABCDEF1234\",\"ledgerCurrency\":\"JPY\",\"businessInfo\":{}}", json); | ||
} | ||
|
||
[Test] | ||
public void RegisterAmazonPayAccountWithIndividualBusinessType() | ||
{ | ||
// arrange | ||
var request = CreateIndividualAccountRequest(); | ||
|
||
// act | ||
string json = request.ToJson(); | ||
|
||
// assert | ||
const string expectedJson = "{\"uniqueReferenceId\":\"ABCDEF12345\",\"ledgerCurrency\":\"JPY\",\"businessInfo\":{\"businessType\":\"INDIVIDUAL\",\"countryOfEstablishment\":\"JP\",\"businessLegalName\":\"TestingSubmerchant\",\"businessAddress\":{\"addressLine1\":\"450\",\"addressLine2\":\"Noda\",\"city\":\"香取市\",\"stateOrRegion\":\"千葉県\",\"postalCode\":\"289-0314\",\"countryCode\":\"JP\"}}}"; | ||
Assert.AreEqual(expectedJson, json); | ||
} | ||
|
||
[Test] | ||
public void RegisterAmazonPayAccountWithCorporateBusinessTypeAndWithoutPoc() | ||
{ | ||
// arrange | ||
var request = CreateCorporateAccountRequest(); | ||
|
||
// act | ||
string json = request.ToJson(); | ||
|
||
// assert | ||
const string expectedJson = "{\"uniqueReferenceId\":\"ABCDEF12345\",\"ledgerCurrency\":\"JPY\",\"businessInfo\":{\"businessType\":\"CORPORATE\",\"countryOfEstablishment\":\"JP\",\"businessLegalName\":\"TestingSubmerchant\",\"businessAddress\":{\"addressLine1\":\"450\",\"addressLine2\":\"Noda\",\"city\":\"香取市\",\"stateOrRegion\":\"千葉県\",\"postalCode\":\"289-0314\",\"countryCode\":\"JP\"}}}"; | ||
Assert.AreEqual(expectedJson, json); | ||
} | ||
|
||
[Test] | ||
public void RegisterAmazonPayAccountWithCorporateBusinessTypeAndPoc() | ||
{ | ||
// arrange | ||
var request = CreateCorporateAccountRequestWithPoc(); | ||
|
||
// act | ||
string json = request.ToJson(); | ||
|
||
// assert | ||
const string expectedJson = "{\"uniqueReferenceId\":\"ABCDEF12345\",\"ledgerCurrency\":\"JPY\",\"businessInfo\":{\"businessType\":\"CORPORATE\",\"countryOfEstablishment\":\"JP\",\"businessLegalName\":\"TestingSubmerchant\",\"businessAddress\":{\"addressLine1\":\"450\",\"addressLine2\":\"Noda\",\"city\":\"香取市\",\"stateOrRegion\":\"千葉県\",\"postalCode\":\"289-0314\",\"countryCode\":\"JP\"}},\"primaryContactPerson\":{\"personFullName\":\"Testing\",\"residentialAddress\":{\"addressLine1\":\"621-4\",\"addressLine2\":\"Haramanda\",\"city\":\"Arao City\",\"stateOrRegion\":\"Kumamoto\",\"postalCode\":\"836-0806\",\"countryCode\":\"JP\"}}}"; | ||
Assert.AreEqual(expectedJson, json); | ||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
Amazon.Pay.API.SDK.Tests/WebStore/AccountManagement/UpdateAmazonPayAccountRequestTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using Amazon.Pay.API.WebStore.AccountManagement; | ||
using Amazon.Pay.API.WebStore.Types; | ||
using NUnit.Framework; | ||
|
||
namespace Amazon.Pay.API.Tests.WebStore.AccountManagement | ||
{ | ||
[TestFixture] | ||
public class UpdateAmazonPayAccountRequestTests | ||
{ | ||
[Test] | ||
public void CanConstructWithAllPropertiesInitialized() | ||
{ | ||
// act | ||
var request = new UpdateAmazonPayAccountRequest(); | ||
|
||
// assert | ||
Assert.IsNotNull(request); | ||
Assert.IsNotNull(request.BusinessInfo); | ||
} | ||
|
||
[Test] | ||
public void CanConvertToJsonMinimal() | ||
{ | ||
// arrange | ||
var request = new UpdateAmazonPayAccountRequest(); | ||
|
||
// act | ||
string json = request.ToJson(); | ||
|
||
// assert | ||
Assert.AreEqual("{\"businessInfo\":{}}", json); | ||
} | ||
|
||
private UpdateAmazonPayAccountRequest CreateUpdatePayload() | ||
{ | ||
var request = new UpdateAmazonPayAccountRequest() | ||
{ | ||
BusinessInfo = { | ||
BusinessAddress = { | ||
AddressLine1 = "41", | ||
AddressLine2 = "Nishigamo Kitaimaharacho", | ||
City = "京都市", | ||
StateOrRegion = "京都府", | ||
PostalCode = "683-8821", | ||
CountryCode = "JP" | ||
} | ||
} | ||
}; | ||
return request; | ||
} | ||
|
||
[Test] | ||
public void UpdateAmazonPayAccount() | ||
{ | ||
// arrange | ||
var request = CreateUpdatePayload(); | ||
|
||
// act | ||
string json = request.ToJson(); | ||
|
||
// assert | ||
const string expectedJson = "{\"businessInfo\":{\"businessAddress\":{\"addressLine1\":\"41\",\"addressLine2\":\"Nishigamo Kitaimaharacho\",\"city\":\"京都市\",\"stateOrRegion\":\"京都府\",\"postalCode\":\"683-8821\",\"countryCode\":\"JP\"}}}"; | ||
|
||
Assert.AreEqual(expectedJson, json); | ||
} | ||
|
||
[Test] | ||
public void UpdateAmazonPayAccountWithPrimaryContactPerson() | ||
{ | ||
// arrange | ||
var request = CreateUpdatePayload(); | ||
request.BusinessInfo.BusinessType = BusinessType.CORPORATE; | ||
request.BusinessInfo.CountryOfEstablishment = "JP"; | ||
request.BusinessInfo.BusinessLegalName = "TestingSubmerchant"; | ||
request.PrimaryContactPerson.DateOfBirth = "19971111"; | ||
request.PrimaryContactPerson.PersonFullName = "Test"; | ||
|
||
// act | ||
string json = request.ToJson(); | ||
|
||
// assert | ||
const string expectedJson = "{\"businessInfo\":{\"businessType\":\"CORPORATE\",\"countryOfEstablishment\":\"JP\",\"businessLegalName\":\"TestingSubmerchant\",\"businessAddress\":{\"addressLine1\":\"41\",\"addressLine2\":\"Nishigamo Kitaimaharacho\",\"city\":\"京都市\",\"stateOrRegion\":\"京都府\",\"postalCode\":\"683-8821\",\"countryCode\":\"JP\"}},\"primaryContactPerson\":{\"personFullName\":\"Test\",\"dateOfBirth\":\"19971111\"}}"; | ||
Assert.AreEqual(expectedJson, json); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
Amazon.Pay.API.SDK.Tests/WebStore/CheckoutSession/FinalizeCheckoutSessionRequestTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using Amazon.Pay.API.Types; | ||
using Amazon.Pay.API.WebStore.CheckoutSession; | ||
using Amazon.Pay.API.WebStore.Types; | ||
using NUnit.Framework; | ||
|
||
namespace Amazon.Pay.API.Tests.WebStore.CheckoutSession | ||
{ | ||
[TestFixture] | ||
public class FinalizeCheckoutSessionRequestTests | ||
{ | ||
[Test] | ||
public void CanConvertToJsonMinimal() | ||
{ | ||
// arrange | ||
var request = new FinalizeCheckoutSessionRequest(10, Currency.USD, PaymentIntent.Confirm); | ||
|
||
// act | ||
string json = request.ToJson(); | ||
|
||
// assert | ||
Assert.AreEqual("{\"paymentIntent\":\"Confirm\",\"chargeAmount\":{\"amount\":10,\"currencyCode\":\"USD\"}}", json); | ||
} | ||
|
||
[Test] | ||
public void CanConstructWithAllPropertiesInitialized() | ||
{ | ||
// act | ||
var request = new FinalizeCheckoutSessionRequest(10, Currency.USD, PaymentIntent.Confirm); | ||
|
||
// assert | ||
Assert.IsNotNull(request); | ||
Assert.IsNotNull(request.ShippingAddress); | ||
Assert.IsNotNull(request.ChargeAmount); | ||
Assert.IsNotNull(request.TotalOrderAmount); | ||
Assert.IsNotNull(request.PaymentIntent); | ||
} | ||
|
||
[Test] | ||
public void FinalizeCheckoutSessionResponseTest() | ||
{ | ||
// arrange | ||
var request = new FinalizeCheckoutSessionRequest(amount: 10, currency: Currency.USD, PaymentIntent.Confirm); | ||
request.ShippingAddress.Name = "Susie Smith"; | ||
request.ShippingAddress.AddressLine1 = "10 Ditka Ave"; | ||
request.ShippingAddress.AddressLine2 = "Suite 2500"; | ||
request.ShippingAddress.City = "Chicago"; | ||
request.ShippingAddress.County = null; | ||
request.ShippingAddress.District = null; | ||
request.ShippingAddress.StateOrRegion = "IL"; | ||
request.ShippingAddress.PostalCode = "60602"; | ||
request.ShippingAddress.CountryCode = "US"; | ||
request.ShippingAddress.PhoneNumber = "800-000-0000"; | ||
request.TotalOrderAmount.Amount = 10; | ||
request.TotalOrderAmount.CurrencyCode = Currency.USD; | ||
request.CanHandlePendingAuthorization = false; | ||
|
||
// act | ||
string json = request.ToJson(); | ||
// assert | ||
Assert.AreEqual("{\"paymentIntent\":\"Confirm\",\"canHandlePendingAuthorization\":false,\"shippingAddress\":{\"name\":\"Susie Smith\",\"phoneNumber\":\"800-000-0000\",\"addressLine1\":\"10 Ditka Ave\",\"addressLine2\":\"Suite 2500\",\"city\":\"Chicago\",\"stateOrRegion\":\"IL\",\"postalCode\":\"60602\",\"countryCode\":\"US\"},\"chargeAmount\":{\"amount\":10,\"currencyCode\":\"USD\"},\"totalOrderAmount\":{\"amount\":10,\"currencyCode\":\"USD\"}}", json); | ||
} | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
Amazon.Pay.API.SDK.Tests/WebStore/Interfaces/IMerchantOnboardingClientTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System.Collections.Generic; | ||
using Amazon.Pay.API.WebStore.AccountManagement; | ||
using Amazon.Pay.API.WebStore.Types; | ||
using Amazon.Pay.API.WebStore.Interfaces; | ||
using Moq; | ||
using NUnit.Framework; | ||
|
||
namespace Amazon.Pay.API.SDK.Tests.WebStore.Interfaces | ||
{ | ||
// This is a test fixture to ensure that a method can be mocked and helps ensure it is on the interface. | ||
[TestFixture] | ||
public class IMerchantOnboardingClientTests | ||
{ | ||
private Mock<IMerchantOnboardingClient> mockMerchantOnboardingClient; | ||
|
||
[OneTimeSetUp] | ||
public void Init() | ||
{ | ||
this.mockMerchantOnboardingClient = new Mock<IMerchantOnboardingClient>(MockBehavior.Strict); | ||
} | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
this.mockMerchantOnboardingClient.Reset(); | ||
} | ||
|
||
// ------------ Testing the Merchant Onboarding & Account Management APIs --------------- | ||
|
||
[Test] | ||
public void RegisterAmazonPayAccountCanBeMocked() | ||
{ | ||
var registerAmazonPayAccountResponse = new RegisterAmazonPayAccountResponse(); | ||
this.mockMerchantOnboardingClient.Setup(mwsc => mwsc.RegisterAmazonPayAccount(It.IsAny<RegisterAmazonPayAccountRequest>(), It.IsAny<Dictionary<string, string>>())).Returns(registerAmazonPayAccountResponse); | ||
|
||
var result = this.mockMerchantOnboardingClient.Object.RegisterAmazonPayAccount(new RegisterAmazonPayAccountRequest("ABCD12345", LedgerCurrency.JPY), new Dictionary<string, string>()); | ||
|
||
Assert.That(result, Is.EqualTo(registerAmazonPayAccountResponse)); | ||
this.mockMerchantOnboardingClient.Verify(mwsc => mwsc.RegisterAmazonPayAccount(It.IsAny<RegisterAmazonPayAccountRequest>(), It.IsAny<Dictionary<string, string>>()), Times.Once); | ||
} | ||
|
||
[Test] | ||
public void UpdateAmazonPayAccountCanBeMocked() | ||
{ | ||
var updateAmazonPayAccountResponse = new UpdateAmazonPayAccountResponse(); | ||
this.mockMerchantOnboardingClient.Setup(mwsc => mwsc.UpdateAmazonPayAccount(It.IsAny<string>(), It.IsAny<UpdateAmazonPayAccountRequest>(), It.IsAny<Dictionary<string, string>>())).Returns(updateAmazonPayAccountResponse); | ||
|
||
var result = this.mockMerchantOnboardingClient.Object.UpdateAmazonPayAccount("SessionId", new UpdateAmazonPayAccountRequest(), new Dictionary<string, string>()); | ||
|
||
Assert.That(result, Is.EqualTo(updateAmazonPayAccountResponse)); | ||
this.mockMerchantOnboardingClient.Verify(mwsc => mwsc.UpdateAmazonPayAccount(It.IsAny<string>(), It.IsAny<UpdateAmazonPayAccountRequest>(), It.IsAny<Dictionary<string, string>>()), Times.Once); | ||
} | ||
|
||
[Test] | ||
public void DeleteAmazonPayAccountCanBeMocked() | ||
{ | ||
var deleteAmazonPayAccountResponse = new DeleteAmazonPayAccountResponse(); | ||
this.mockMerchantOnboardingClient.Setup(mwsc => mwsc.DeleteAmazonPayAccount("merchantAccountId", It.IsAny<Dictionary<string, string>>())).Returns(deleteAmazonPayAccountResponse); | ||
|
||
var result = this.mockMerchantOnboardingClient.Object.DeleteAmazonPayAccount("merchantAccountId", new Dictionary<string, string>()); | ||
|
||
Assert.That(result, Is.EqualTo(deleteAmazonPayAccountResponse)); | ||
this.mockMerchantOnboardingClient.Verify(mwsc => mwsc.DeleteAmazonPayAccount("merchantAccountId", It.IsAny<Dictionary<string, string>>()), Times.Once); | ||
} | ||
} | ||
} |
Oops, something went wrong.