mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-15 18:14:44 +00:00
Load the current avatar photo alongside user accounts
This commit is contained in:
@@ -47,4 +47,43 @@ public class GetAllUsersHandlerTests
|
||||
|
||||
result.Should().ContainSingle().Which.Should().BeEquivalentTo(user.ToPublicProfileDto());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Handle_MapsEachUsersOwnAvatarUrl()
|
||||
{
|
||||
Mock<IUserListRepository> repoMock = new();
|
||||
GetAllUsersHandler handler = new(repoMock.Object);
|
||||
UserAccount withAvatar = new()
|
||||
{
|
||||
UserAccountId = Guid.NewGuid(),
|
||||
Username = "has-avatar",
|
||||
FirstName = "Has",
|
||||
LastName = "Avatar",
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UserProfile = new UserProfile { Biography = "Drinks lagers." },
|
||||
UserAvatar = new UserAvatar
|
||||
{
|
||||
Photo = new Photo { Hyperlink = "https://cdn.example.com/avatar.jpg" },
|
||||
},
|
||||
};
|
||||
UserAccount withoutAvatar = new()
|
||||
{
|
||||
UserAccountId = Guid.NewGuid(),
|
||||
Username = "no-avatar",
|
||||
FirstName = "No",
|
||||
LastName = "Avatar",
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
};
|
||||
repoMock.Setup(r => r.GetAllAsync(null, null)).ReturnsAsync([withAvatar, withoutAvatar]);
|
||||
|
||||
IEnumerable<PublicUserProfileDto> result = await handler.Handle(
|
||||
new GetAllUsersQuery(null, null),
|
||||
CancellationToken.None
|
||||
);
|
||||
|
||||
result
|
||||
.Select(dto => dto.AvatarUrl)
|
||||
.Should()
|
||||
.Equal("https://cdn.example.com/avatar.jpg", string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user