Skip to content

Commit

Permalink
Ensure that Leaderboard is created and returned.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTedder committed Sep 22, 2024
1 parent 279e66c commit 35a1e52
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions LeaderboardBackend.Test/Leaderboards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,25 @@ public async Task DeletedBoardsDontConsumeSlugs()
context.Leaderboards.Add(deletedBoard);
await context.SaveChangesAsync();
deletedBoard.Id.Should().NotBe(default);
context.ChangeTracker.Clear();
Leaderboard? retrieved = await context.Leaderboards.FindAsync(deletedBoard.Id);
retrieved.Should().NotBeNull();

await FluentActions.Awaiting(() => _apiClient.Post<LeaderboardViewModel>("/leaderboards/create", new()
CreateLeaderboardRequest lbRequest = new()
{
Body = new CreateLeaderboardRequest()
{
Name = "Super Mario World",
Info = "new and improved",
Slug = "super-mario-world"
},
Name = "Super Mario World",
Info = "new and improved",
Slug = "super-mario-world"
};

#pragma warning disable IDE0008 // Use explicit type
var res = await FluentActions.Awaiting(() => _apiClient.Post<LeaderboardViewModel>("/leaderboards/create", new()
{
Body = lbRequest,
Jwt = _jwt
})).Should().NotThrowAsync();
#pragma warning restore IDE0008 // Use explicit type

Leaderboard? created = await context.Leaderboards.FindAsync(res.Subject.Id);
created.Should().NotBeNull().And.BeEquivalentTo(lbRequest);
created!.CreatedAt.Should().Be(_clock.GetCurrentInstant());
}

private static string ListToQueryString<T>(IEnumerable<T> list, string key)
Expand Down

0 comments on commit 35a1e52

Please sign in to comment.