Skip to content

Commit

Permalink
#167 Added integration test for GetCurrencyByID.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonGeering committed Apr 8, 2021
1 parent 3c387a4 commit fafd23a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/AdminAssistant.Infra/DAL/EntityFramework/Model/CoreSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/// <summary>Sets up static lookup data for the core module.</summary>
Expand All @@ -18,15 +20,13 @@ public static class CoreSchema
/// <returns>Out of the box default currencies.</returns>
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 };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
#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;
using Xunit;

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<ICurrencyRepository>();
var aud = await dal.SaveAsync(new Currency() { DecimalFormat = CoreSchema.DefaultCurrencyDecimalFormat, Symbol = "AUD" }).ConfigureAwait(false);

// Act
var response = await Container.GetRequiredService<IAdminAssistantWebAPIClient>().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
{
Expand Down

0 comments on commit fafd23a

Please sign in to comment.