mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-07-16 17:47:22 +00:00
Format ./web/backend/Features/Features.UserManagement.Tests
This commit is contained in:
@@ -15,7 +15,10 @@ public class GetAllUsersHandlerTests
|
|||||||
GetAllUsersHandler handler = new(repoMock.Object);
|
GetAllUsersHandler handler = new(repoMock.Object);
|
||||||
repoMock.Setup(r => r.GetAllAsync(10, 5)).ReturnsAsync(Array.Empty<UserAccount>());
|
repoMock.Setup(r => r.GetAllAsync(10, 5)).ReturnsAsync(Array.Empty<UserAccount>());
|
||||||
|
|
||||||
IEnumerable<UserAccount> result = await handler.Handle(new GetAllUsersQuery(10, 5), CancellationToken.None);
|
IEnumerable<UserAccount> result = await handler.Handle(
|
||||||
|
new GetAllUsersQuery(10, 5),
|
||||||
|
CancellationToken.None
|
||||||
|
);
|
||||||
|
|
||||||
result.Should().BeEmpty();
|
result.Should().BeEmpty();
|
||||||
repoMock.Verify(r => r.GetAllAsync(10, 5), Times.Once);
|
repoMock.Verify(r => r.GetAllAsync(10, 5), Times.Once);
|
||||||
|
|||||||
@@ -23,7 +23,10 @@ public class GetUserByIdHandlerTests
|
|||||||
UserAccount user = new() { UserAccountId = Guid.NewGuid(), Username = "test" };
|
UserAccount user = new() { UserAccountId = Guid.NewGuid(), Username = "test" };
|
||||||
_repoMock.Setup(r => r.GetByIdAsync(user.UserAccountId)).ReturnsAsync(user);
|
_repoMock.Setup(r => r.GetByIdAsync(user.UserAccountId)).ReturnsAsync(user);
|
||||||
|
|
||||||
UserAccount result = await _handler.Handle(new GetUserByIdQuery(user.UserAccountId), CancellationToken.None);
|
UserAccount result = await _handler.Handle(
|
||||||
|
new GetUserByIdQuery(user.UserAccountId),
|
||||||
|
CancellationToken.None
|
||||||
|
);
|
||||||
|
|
||||||
result.Should().Be(user);
|
result.Should().Be(user);
|
||||||
}
|
}
|
||||||
@@ -34,7 +37,8 @@ public class GetUserByIdHandlerTests
|
|||||||
Guid id = Guid.NewGuid();
|
Guid id = Guid.NewGuid();
|
||||||
_repoMock.Setup(r => r.GetByIdAsync(id)).ReturnsAsync((UserAccount?)null);
|
_repoMock.Setup(r => r.GetByIdAsync(id)).ReturnsAsync((UserAccount?)null);
|
||||||
|
|
||||||
Func<Task<UserAccount>> act = async () => await _handler.Handle(new GetUserByIdQuery(id), CancellationToken.None);
|
Func<Task<UserAccount>> act = async () =>
|
||||||
|
await _handler.Handle(new GetUserByIdQuery(id), CancellationToken.None);
|
||||||
|
|
||||||
await act.Should().ThrowAsync<NotFoundException>();
|
await act.Should().ThrowAsync<NotFoundException>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,19 +98,14 @@ public class UserAccountRepositoryTests
|
|||||||
UserAccountRepository repo = CreateRepo(conn);
|
UserAccountRepository repo = CreateRepo(conn);
|
||||||
List<UserAccount> results = (await repo.GetAllAsync(null, null)).ToList();
|
List<UserAccount> results = (await repo.GetAllAsync(null, null)).ToList();
|
||||||
results.Should().HaveCount(2);
|
results.Should().HaveCount(2);
|
||||||
results
|
results.Select(r => r.Username).Should().BeEquivalentTo("a", "b");
|
||||||
.Select(r => r.Username)
|
|
||||||
.Should()
|
|
||||||
.BeEquivalentTo("a", "b");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetByUsername_ReturnsRow()
|
public async Task GetByUsername_ReturnsRow()
|
||||||
{
|
{
|
||||||
MockDbConnection conn = new();
|
MockDbConnection conn = new();
|
||||||
conn.Mocks.When(cmd =>
|
conn.Mocks.When(cmd => cmd.CommandText == "usp_GetUserAccountByUsername")
|
||||||
cmd.CommandText == "usp_GetUserAccountByUsername"
|
|
||||||
)
|
|
||||||
.ReturnsTable(
|
.ReturnsTable(
|
||||||
MockTable
|
MockTable
|
||||||
.WithColumns(
|
.WithColumns(
|
||||||
|
|||||||
Reference in New Issue
Block a user