Skip to content

Commit

Permalink
Reorganize Traits tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sliekens committed Sep 16, 2023
1 parent 43dd383 commit 43ce355
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 81 deletions.
20 changes: 20 additions & 0 deletions GW2SDK.Tests/Features/Traits/TraitById.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.Traits;

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

const int id = 214;

var actual = await sut.Traits.GetTraitById(id);

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

namespace GuildWars2.Tests.Features.Traits;

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

var actual = await sut.Traits.GetTraits();

Assert.Equal(actual.ResultContext.ResultTotal, actual.Value.Count);
Assert.All(
actual.Value,
trait =>
{
trait.Id_is_positive();
}
);
}
}
31 changes: 31 additions & 0 deletions GW2SDK.Tests/Features/Traits/TraitsByFilter.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.Traits;

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

HashSet<int> ids = new()
{
214,
221,
222
};

var actual = await sut.Traits.GetTraitsByIds(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/Traits/TraitsByPage.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.Traits;

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

var actual = await sut.Traits.GetTraitsByPage(0, 3);

Assert.Equal(3, actual.Value.Count);
Assert.Equal(3, actual.PageContext.PageSize);
}
}
18 changes: 18 additions & 0 deletions GW2SDK.Tests/Features/Traits/TraitsIndex.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.Traits;

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

var actual = await sut.Traits.GetTraitsIndex();

Assert.Equal(actual.ResultContext.ResultTotal, actual.Value.Count);
}
}
81 changes: 0 additions & 81 deletions GW2SDK.Tests/Features/Traits/TraitsQueryTest.cs

This file was deleted.

0 comments on commit 43ce355

Please sign in to comment.