-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(discussions): return Not Found if no discussions found by author
- Loading branch information
Showing
2 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
tests/CrowdParlay.Social.IntegrationTests/Tests/DiscussionsRepositoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
namespace CrowdParlay.Social.IntegrationTests.Tests; | ||
|
||
public class DiscussionsRepositoryTests(WebApplicationContext context) : IClassFixture<WebApplicationContext> | ||
{ | ||
private readonly IServiceProvider _services = context.Services; | ||
|
||
[Fact(DisplayName = "Get discussions by author")] | ||
public async Task GetDiscussionsByAuthor() | ||
{ | ||
// Arrange | ||
await using var scope = _services.CreateAsyncScope(); | ||
var authors = scope.ServiceProvider.GetRequiredService<IAuthorRepository>(); | ||
var discussions = scope.ServiceProvider.GetRequiredService<IDiscussionRepository>(); | ||
|
||
var author = await authors.CreateAsync( | ||
id: Guid.NewGuid(), | ||
username: "compartmental", | ||
displayName: "Степной ишак", | ||
avatarUrl: null); | ||
|
||
DiscussionDto[] expected = | ||
[ | ||
await discussions.CreateAsync(author.Id, "Discussion 1", "bla bla bla"), | ||
await discussions.CreateAsync(author.Id, "Discussion 2", "numa numa e") | ||
]; | ||
|
||
// Act | ||
var response = await discussions.GetByAuthorAsync(author.Id); | ||
|
||
// Assert | ||
response.Should().BeEquivalentTo(expected); | ||
} | ||
|
||
[Fact(DisplayName = "Get discussions by author of no discussions")] | ||
public async Task GetNoDiscussionsByAuthor() | ||
{ | ||
// Arrange | ||
await using var scope = _services.CreateAsyncScope(); | ||
var authors = scope.ServiceProvider.GetRequiredService<IAuthorRepository>(); | ||
var discussions = scope.ServiceProvider.GetRequiredService<IDiscussionRepository>(); | ||
|
||
var author = await authors.CreateAsync( | ||
id: Guid.NewGuid(), | ||
username: "compartmental", | ||
displayName: "Степной ишак", | ||
avatarUrl: null); | ||
|
||
// Act | ||
var response = await discussions.GetByAuthorAsync(author.Id); | ||
|
||
// Assert | ||
response.Should().BeEmpty(); | ||
} | ||
} |