diff --git a/src/AdminAssistant.Infra/DAL/EntityFramework/Model/CoreSchema.cs b/src/AdminAssistant.Infra/DAL/EntityFramework/Model/CoreSchema.cs index 0ee29846..e80d79ad 100644 --- a/src/AdminAssistant.Infra/DAL/EntityFramework/Model/CoreSchema.cs +++ b/src/AdminAssistant.Infra/DAL/EntityFramework/Model/CoreSchema.cs @@ -6,6 +6,8 @@ namespace AdminAssistant.Infra.DAL.EntityFramework.Model.Core { public static class CoreSchema { + public const string DefaultCurrencyDecimalFormat = "2.2-2"; + private const string Name = "Core"; /// Sets up static lookup data for the core module. @@ -18,15 +20,13 @@ public static class CoreSchema /// Out of the box default currencies. public static CurrencyEntity[] GetCurrencySeedData(bool includeIDs = false) { - const string defaultDecimalFormat = "2.2-2"; - - var GBP = new CurrencyEntity { Symbol = "GBP", DecimalFormat = defaultDecimalFormat }; + var GBP = new CurrencyEntity { Symbol = "GBP", DecimalFormat = DefaultCurrencyDecimalFormat }; if (includeIDs) GBP.CurrencyID = 1; - var EUR = new CurrencyEntity { Symbol = "EUR", DecimalFormat = defaultDecimalFormat }; + var EUR = new CurrencyEntity { Symbol = "EUR", DecimalFormat = DefaultCurrencyDecimalFormat }; if (includeIDs) EUR.CurrencyID = 2; - var USD = new CurrencyEntity { Symbol = "USD", DecimalFormat = defaultDecimalFormat }; + var USD = new CurrencyEntity { Symbol = "USD", DecimalFormat = DefaultCurrencyDecimalFormat }; if (includeIDs) USD.CurrencyID = 3; return new CurrencyEntity[] { GBP, EUR, USD }; diff --git a/src/AdminAssistant.Test/WebAPI/v1/CoreModule/CurrencyController_IntegrationTest.cs b/src/AdminAssistant.Test/WebAPI/v1/CoreModule/CurrencyController_IntegrationTest.cs index f400a78a..880bfcd2 100644 --- a/src/AdminAssistant.Test/WebAPI/v1/CoreModule/CurrencyController_IntegrationTest.cs +++ b/src/AdminAssistant.Test/WebAPI/v1/CoreModule/CurrencyController_IntegrationTest.cs @@ -1,6 +1,9 @@ #if DEBUG // quick and dirty fix for #85 category filtering breaking CI Unit Test run. #pragma warning disable CA1707 // Identifiers should not contain underscores using System.Threading.Tasks; +using AdminAssistant.DomainModel.Modules.CoreModule; +using AdminAssistant.Infra.DAL.EntityFramework.Model.Core; +using AdminAssistant.Infra.DAL.Modules.CoreModule; using AdminAssistant.UI.Shared.WebAPIClient.v1; using FluentAssertions; using Microsoft.Extensions.DependencyInjection; @@ -8,6 +11,29 @@ namespace AdminAssistant.WebAPI.v1.CoreModule { + [Collection("SequentialDBBackedTests")] + public class Currency_GetById_Should : IntegrationTestBase + { + [Fact] + [Trait("Category", "Integration")] + public async Task Return_ACurrency_Given_CurrencyID() + { + // Arrange + await ResetDatabaseAsync().ConfigureAwait(false); + + var dal = Container.GetRequiredService(); + var aud = await dal.SaveAsync(new Currency() { DecimalFormat = CoreSchema.DefaultCurrencyDecimalFormat, Symbol = "AUD" }).ConfigureAwait(false); + + // Act + var response = await Container.GetRequiredService().GetCurrencyByIdAsync(aud.CurrencyID).ConfigureAwait(false); + + // Assert + response.CurrencyID.Should().Be(aud.CurrencyID); + response.DecimalFormat.Should().Be(aud.DecimalFormat); + response.Symbol.Should().Be(aud.Symbol); + } + } + [Collection("SequentialDBBackedTests")] public class Currency_Get_Should : IntegrationTestBase {