From 35a1e525f8d50576f7899bb010ab1abf55496ed2 Mon Sep 17 00:00:00 2001 From: Ted Wollman <25165500+TheTedder@users.noreply.github.com> Date: Sun, 22 Sep 2024 19:41:37 -0400 Subject: [PATCH] Ensure that Leaderboard is created and returned. --- LeaderboardBackend.Test/Leaderboards.cs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/LeaderboardBackend.Test/Leaderboards.cs b/LeaderboardBackend.Test/Leaderboards.cs index a0631ccd..be4e9075 100644 --- a/LeaderboardBackend.Test/Leaderboards.cs +++ b/LeaderboardBackend.Test/Leaderboards.cs @@ -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("/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("/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(IEnumerable list, string key)