Skip to content

Commit a2bb5fb

Browse files
committed
Reorganize Worlds tests
1 parent 43ce355 commit a2bb5fb

File tree

6 files changed

+115
-83
lines changed

6 files changed

+115
-83
lines changed
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Threading.Tasks;
2+
using GuildWars2.Tests.TestInfrastructure;
3+
using Xunit;
4+
5+
namespace GuildWars2.Tests.Features.Worlds;
6+
7+
public class WorldById
8+
{
9+
[Fact]
10+
public async Task Can_be_found()
11+
{
12+
var sut = Composer.Resolve<Gw2Client>();
13+
14+
const int id = 1001;
15+
16+
var actual = await sut.Worlds.GetWorldById(id);
17+
18+
Assert.Equal(id, actual.Value.Id);
19+
}
20+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Threading.Tasks;
2+
using GuildWars2.Tests.TestInfrastructure;
3+
using Xunit;
4+
5+
namespace GuildWars2.Tests.Features.Worlds;
6+
7+
public class Worlds
8+
{
9+
[Fact]
10+
public async Task Can_be_listed()
11+
{
12+
var sut = Composer.Resolve<Gw2Client>();
13+
14+
var actual = await sut.Worlds.GetWorlds();
15+
16+
Assert.Equal(actual.ResultContext.ResultTotal, actual.Value.Count);
17+
Assert.All(
18+
actual.Value,
19+
world =>
20+
{
21+
world.Id_is_positive();
22+
world.Name_is_not_empty();
23+
world.World_population_type_is_supported();
24+
}
25+
);
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using GuildWars2.Tests.TestInfrastructure;
4+
using Xunit;
5+
6+
namespace GuildWars2.Tests.Features.Worlds;
7+
8+
public class WorldsByFilter
9+
{
10+
[Fact]
11+
public async Task Can_be_filtered_by_id()
12+
{
13+
var sut = Composer.Resolve<Gw2Client>();
14+
15+
HashSet<int> ids = new()
16+
{
17+
1001,
18+
1002,
19+
1003
20+
};
21+
22+
var actual = await sut.Worlds.GetWorldsByIds(ids);
23+
24+
Assert.Collection(
25+
ids,
26+
first => Assert.Contains(actual.Value, found => found.Id == first),
27+
second => Assert.Contains(actual.Value, found => found.Id == second),
28+
third => Assert.Contains(actual.Value, found => found.Id == third)
29+
);
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Threading.Tasks;
2+
using GuildWars2.Tests.TestInfrastructure;
3+
using Xunit;
4+
5+
namespace GuildWars2.Tests.Features.Worlds;
6+
7+
public sealed class WorldsByPage
8+
{
9+
[Fact]
10+
public async Task Can_be_filtered_by_page()
11+
{
12+
var sut = Composer.Resolve<Gw2Client>();
13+
14+
var actual = await sut.Worlds.GetWorldsByPage(0, 3);
15+
16+
Assert.Equal(3, actual.Value.Count);
17+
Assert.Equal(3, actual.PageContext.PageSize);
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Threading.Tasks;
2+
using GuildWars2.Tests.TestInfrastructure;
3+
using Xunit;
4+
5+
namespace GuildWars2.Tests.Features.Worlds;
6+
7+
public class WorldsIndex
8+
{
9+
[Fact]
10+
public async Task Is_not_empty()
11+
{
12+
var sut = Composer.Resolve<Gw2Client>();
13+
14+
var actual = await sut.Worlds.GetWorldsIndex();
15+
16+
Assert.Equal(actual.ResultContext.ResultTotal, actual.Value.Count);
17+
}
18+
}

GW2SDK.Tests/Features/Worlds/WorldsQueryTest.cs

-83
This file was deleted.

0 commit comments

Comments
 (0)