Skip to content

Commit

Permalink
Reorganize currencies tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sliekens committed Sep 15, 2023
1 parent a38d12e commit 2c91eaa
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 106 deletions.
38 changes: 38 additions & 0 deletions GW2SDK.Tests/Features/Currencies/Currencies.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Threading.Tasks;
using GuildWars2.Tests.TestInfrastructure;
using Xunit;

namespace GuildWars2.Tests.Features.Currencies;

public class Currencies
{
[Fact]
public async Task Can_be_listed()
{
var sut = Composer.Resolve<Gw2Client>();

var actual = await sut.Wallet.GetCurrencies();

Assert.Equal(actual.ResultContext.ResultTotal, actual.Value.Count);
Assert.All(
actual.Value,
currency =>
{
currency.Id_is_positive();
currency.Name_is_not_empty();
if (currency.Id == 63)
{
// Astral Acclaim is missing a tooltip
Assert.Empty(currency.Description);
}
else
{
currency.Description_is_not_empty();
}
currency.Order_is_positive();
currency.Icon_is_not_empty();
}
);
}
}
31 changes: 31 additions & 0 deletions GW2SDK.Tests/Features/Currencies/CurrenciesByFilter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using GuildWars2.Tests.TestInfrastructure;
using Xunit;

namespace GuildWars2.Tests.Features.Currencies;

public class CurrenciesByFilter
{
[Fact]
public async Task Can_be_filtered_by_id()
{
var sut = Composer.Resolve<Gw2Client>();

HashSet<int> ids = new()
{
1,
2,
3
};

var actual = await sut.Wallet.GetCurrenciesByIds(ids);

Assert.Collection(
ids,
first => Assert.Contains(actual.Value, found => found.Id == first),
second => Assert.Contains(actual.Value, found => found.Id == second),
third => Assert.Contains(actual.Value, found => found.Id == third)
);
}
}
19 changes: 19 additions & 0 deletions GW2SDK.Tests/Features/Currencies/CurrenciesByPage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Threading.Tasks;
using GuildWars2.Tests.TestInfrastructure;
using Xunit;

namespace GuildWars2.Tests.Features.Currencies;

public class CurrenciesByPage
{
[Fact]
public async Task Currencies_can_be_filtered_by_page()
{
var sut = Composer.Resolve<Gw2Client>();

var actual = await sut.Wallet.GetCurrenciesByPage(0, 3);

Assert.Equal(3, actual.Value.Count);
Assert.Equal(3, actual.PageContext.PageSize);
}
}
18 changes: 18 additions & 0 deletions GW2SDK.Tests/Features/Currencies/CurrenciesIndex.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Threading.Tasks;
using GuildWars2.Tests.TestInfrastructure;
using Xunit;

namespace GuildWars2.Tests.Features.Currencies;

public class CurrenciesIndex
{
[Fact]
public async Task Is_not_empty()
{
var sut = Composer.Resolve<Gw2Client>();

var actual = await sut.Wallet.GetCurrenciesIndex();

Assert.Equal(actual.ResultContext.ResultTotal, actual.Value.Count);
}
}
20 changes: 20 additions & 0 deletions GW2SDK.Tests/Features/Currencies/CurrencyById.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Threading.Tasks;
using GuildWars2.Tests.TestInfrastructure;
using Xunit;

namespace GuildWars2.Tests.Features.Currencies;

public class CurrencyById
{
[Fact]
public async Task A_currency_can_be_found_by_id()
{
var sut = Composer.Resolve<Gw2Client>();

const int id = 1;

var actual = await sut.Wallet.GetCurrencyById(id);

Assert.Equal(id, actual.Value.Id);
}
}
21 changes: 21 additions & 0 deletions GW2SDK.Tests/Features/Currencies/Wallet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using GuildWars2.Tests.TestInfrastructure;
using Xunit;

namespace GuildWars2.Tests.Features.Currencies;

public class Wallet
{
[Fact]
public async Task Can_be_found()
{
var sut = Composer.Resolve<Gw2Client>();
var accessToken = Composer.Resolve<ApiKey>();
var actual = await sut.Wallet.GetWallet(accessToken.Key);
var coins = actual.Value.Single(currency => currency.CurrencyId == 1);
Coin coinsAmount = coins.Amount;
Assert.True(coinsAmount > 0);
}
}
106 changes: 0 additions & 106 deletions GW2SDK.Tests/Features/Currencies/WalletQueryTest.cs

This file was deleted.

0 comments on commit 2c91eaa

Please sign in to comment.