Skip to content

Commit

Permalink
Implement IDE suggestions for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zysim committed Sep 9, 2024
1 parent 9296d24 commit 016c12f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
21 changes: 9 additions & 12 deletions LeaderboardBackend.Test/Categories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,15 @@ public async Task OneTimeSetUp()
public void OneTimeTearDown() => _factory.Dispose();

[Test]
public static void GetCategory_NotFound()
{
RequestFailureException e = Assert.ThrowsAsync<RequestFailureException>(
async () =>
await _apiClient.Get<CategoryViewModel>(
$"/api/categories/69",
new() { Jwt = _jwt }
)
)!;

Assert.AreEqual(HttpStatusCode.NotFound, e.Response.StatusCode);
}
public static async Task GetCategory_NotFound() =>
await _apiClient.Awaiting(
a => a.Get<CategoryViewModel>(
$"/api/cateogries/69",
new() { Jwt = _jwt }
)
).Should()
.ThrowAsync<RequestFailureException>()
.Where(e => e.Response.StatusCode == HttpStatusCode.NotFound);

[Test]
public static async Task CreateCategory_GetCategory_OK()
Expand Down
14 changes: 6 additions & 8 deletions LeaderboardBackend.Test/Runs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public static async Task CreateRun_OK()

RunViewModel retrieved = await GetRun(created.Id);

Assert.NotNull(created);
Assert.AreEqual(created.Id, retrieved.Id);
created.Should().NotBeNull();
created.Id.Should().Be(retrieved.Id);
}

[Test]
Expand All @@ -88,13 +88,12 @@ public static async Task GetCategory_OK()
new() { Jwt = _jwt }
);

Assert.NotNull(category);
Assert.AreEqual(category.Id, _categoryId);
category.Should().NotBeNull();
category.Id.Should().Be(_categoryId);
}

private static async Task<RunViewModel> CreateRun()
{
return await _apiClient.Post<RunViewModel>(
private static async Task<RunViewModel> CreateRun() =>
await _apiClient.Post<RunViewModel>(
"/runs/create",
new()
{
Expand All @@ -108,7 +107,6 @@ private static async Task<RunViewModel> CreateRun()
Jwt = _jwt
}
);
}

private static async Task<RunViewModel> GetRun(Guid id) =>
await _apiClient.Get<RunViewModel>(
Expand Down

0 comments on commit 016c12f

Please sign in to comment.