Skip to content

Commit

Permalink
Merge pull request #5 from HannaAndreevna/4-extend-the-list-of-suppor…
Browse files Browse the repository at this point in the history
…ted-currencies

4 extend the list of supported currencies
  • Loading branch information
starkmsu authored May 19, 2020
2 parents 3ef3e4a + 4fe568e commit 92e4d28
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace MAVN.Service.PayrexxIntegration.Domain.Enums
{
public enum IntegrationSupportedCurrency
{
CHF,
EUR,
GBP,
USD,
RUR
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ public interface IPartnerIntegrationPropertiesService
Task<PayrexxIntegrationProperties> FetchPropertiesAsync(Guid partnerId);

PayrexxIntegrationProperties DeserializePayrexxIntegrationProperties(string paymentIntegrationProperties);

Task<List<string>> GetIntegrationCurrency();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MAVN.Service.CustomerProfile.Client;
using MAVN.Service.CustomerProfile.Client.Models.Enums;
Expand Down Expand Up @@ -89,5 +90,10 @@ public PayrexxIntegrationProperties DeserializePayrexxIntegrationProperties(stri
ErrorCode = IntegrationPropertiesErrorCode.None,
};
}

public async Task<List<string>> GetIntegrationCurrency()
{
return await Task.FromResult(Enum.GetNames(typeof(IntegrationSupportedCurrency)).ToList());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Task<PaymentIntegrationPropertiesResponse> GetPaymentIntegrationPropertie
[ProducesResponseType(typeof(List<string>), (int)HttpStatusCode.OK)]
public Task<List<string>> GetPaymentIntegrationSupportedCurrenciesAsync()
{
return Task.FromResult(new List<string> { "CHF" });
return _partnerIntegrationPropertiesFetcherService.GetIntegrationCurrency();
}

/// <summary>
Expand Down Expand Up @@ -191,7 +191,7 @@ public async Task<PaymentStatusResponse> CheckPaymentAsync(CheckPaymentRequest r
return result;
}

switch(paymentStatus.Data[0].Status)
switch (paymentStatus.Data[0].Status)
{
case "waiting":
result.PaymentStatus = PaymentStatus.Pending;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using MAVN.Service.CustomerProfile.Client;
using MAVN.Service.PayrexxIntegration.Domain.Enums;
using MAVN.Service.PayrexxIntegration.DomainServices;
using Moq;
using Xunit;

namespace MAVN.Service.PayrexxIntegration.Tests
{
public class PartnerIntegrationPropertiesServiceTest
{

private readonly Mock<ICustomerProfileClient> _customerProfileClient = new Mock<ICustomerProfileClient>();
private readonly string _fakeApiBaseUrl = Guid.NewGuid().ToString();

[Fact]
public async void CheckIntegrationSupportedCurrency_ReturnsNotEmptyStringList()
{
var expectedCount = Enum.GetNames(typeof(IntegrationSupportedCurrency)).Length;

var result = await CreateSutInstance().GetIntegrationCurrency();

Assert.Equal(expectedCount, result.Count);
}

private PartnerIntegrationPropertiesService CreateSutInstance()
{
return new PartnerIntegrationPropertiesService(_customerProfileClient.Object, _fakeApiBaseUrl);
}
}
}

0 comments on commit 92e4d28

Please sign in to comment.