Skip to content

Commit 43dd383

Browse files
committed
Reorganize Backstory tests
1 parent 9bb96d8 commit 43dd383

11 files changed

+235
-163
lines changed
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.Stories;
6+
7+
public class BackstoryAnswerById
8+
{
9+
[Fact]
10+
public async Task Can_be_found()
11+
{
12+
var sut = Composer.Resolve<Gw2Client>();
13+
14+
const string id = "7-53";
15+
16+
var actual = await sut.Stories.GetBackstoryAnswerById(id);
17+
18+
Assert.Equal(id, actual.Value.Id);
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Threading.Tasks;
2+
using GuildWars2.Tests.TestInfrastructure;
3+
using Xunit;
4+
5+
namespace GuildWars2.Tests.Features.Stories;
6+
7+
public class BackstoryAnswers
8+
{
9+
[Fact]
10+
public async Task Can_be_listed()
11+
{
12+
var sut = Composer.Resolve<Gw2Client>();
13+
14+
var actual = await sut.Stories.GetBackstoryAnswers();
15+
16+
Assert.Equal(actual.ResultContext.ResultTotal, actual.Value.Count);
17+
18+
Assert.All(
19+
actual.Value,
20+
answer =>
21+
{
22+
answer.Id_is_not_empty();
23+
answer.Title_is_not_null();
24+
answer.Description_is_not_empty();
25+
answer.Journal_is_not_empty();
26+
answer.Has_a_question();
27+
}
28+
);
29+
}
30+
}
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.Stories;
7+
8+
public class BackstoryAnswersByFilter
9+
{
10+
[Fact]
11+
public async Task Can_be_filtered_by_id()
12+
{
13+
var sut = Composer.Resolve<Gw2Client>();
14+
15+
HashSet<string> ids = new()
16+
{
17+
"7-53",
18+
"7-54",
19+
"7-55"
20+
};
21+
22+
var actual = await sut.Stories.GetBackstoryAnswersByIds(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.Stories;
6+
7+
public class BackstoryAnswersByPage
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.Stories.GetBackstoryAnswersByPage(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.Stories;
6+
7+
public class BackstoryAnswersIndex
8+
{
9+
[Fact]
10+
public async Task Is_not_empty()
11+
{
12+
var sut = Composer.Resolve<Gw2Client>();
13+
14+
var actual = await sut.Stories.GetBackstoryAnswersIndex();
15+
16+
Assert.Equal(actual.ResultContext.ResultTotal, actual.Value.Count);
17+
}
18+
}
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.Stories;
6+
7+
public class BackstoryQuestionById
8+
{
9+
[Fact]
10+
public async Task Can_be_found()
11+
{
12+
var sut = Composer.Resolve<Gw2Client>();
13+
14+
const int id = 7;
15+
16+
var actual = await sut.Stories.GetBackstoryQuestionById(id);
17+
18+
Assert.Equal(id, actual.Value.Id);
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Threading.Tasks;
2+
using GuildWars2.Tests.TestInfrastructure;
3+
using Xunit;
4+
5+
namespace GuildWars2.Tests.Features.Stories;
6+
7+
public class BackstoryQuestions
8+
{
9+
[Fact]
10+
public async Task Can_be_listed()
11+
{
12+
var sut = Composer.Resolve<Gw2Client>();
13+
14+
var actual = await sut.Stories.GetBackstoryQuestions();
15+
16+
Assert.Equal(actual.ResultContext.ResultTotal, actual.Value.Count);
17+
18+
Assert.All(
19+
actual.Value,
20+
question =>
21+
{
22+
question.Id_is_positive();
23+
question.Title_is_not_null();
24+
question.Description_is_not_empty();
25+
question.Has_3_to_8_answers();
26+
}
27+
);
28+
}
29+
}
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.Stories;
7+
8+
public class BackstoryQuestionsByFilter
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+
7,
18+
10,
19+
11
20+
};
21+
22+
var actual = await sut.Stories.GetBackstoryQuestionsByIds(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.Stories;
6+
7+
public class BackstoryQuestionsByPage
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.Stories.GetBackstoryQuestionsByPage(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.Stories;
6+
7+
public class BackstoryQuestionsIndex
8+
{
9+
[Fact]
10+
public async Task Is_not_empty()
11+
{
12+
var sut = Composer.Resolve<Gw2Client>();
13+
14+
var actual = await sut.Stories.GetBackstoryQuestionsIndex();
15+
16+
Assert.Equal(actual.ResultContext.ResultTotal, actual.Value.Count);
17+
}
18+
}

0 commit comments

Comments
 (0)