Files
Musify/backend/Tests/Musify.Application.Tests/Users/GetUsersQueryHandlerTests.cs
T
Admin b5700614c1 Use block-scoped namespaces in the test suite
Converts all 73 test source files from file-scoped (namespace X;) to
block-scoped (namespace X { ... }) declarations, re-indenting their
contents accordingly. Matches the existing convention already used in
several production files (e.g. Musify.Infrastructure.Configuration,
Musify.Application.Contracts).

Mechanical change only, done with a script, verified with a full
rebuild (0 warnings, 0 errors) and test run (257/257 passing).
2026-09-09 23:09:43 +02:00

35 lines
1.2 KiB
C#

using Musify.Application.Tests.TestSupport;
using Musify.Application.Users;
using Xunit;
namespace Musify.Application.Tests.Users
{
public sealed class GetUsersQueryHandlerTests : HandlerTestBase
{
private GetUsersQueryHandler CreateHandler() => new(Database);
[Fact]
public async Task Handle_NoSearch_ReturnsEveryUser()
{
await SeedAsync(TestEntities.User(1, "alice"), TestEntities.User(2, "bob"));
var result = await CreateHandler().Handle(new GetUsersQuery(PageNumber: 1, PageSize: 10, UsernameSearch: null), TestContext.Current.CancellationToken);
Assert.False(result.IsError);
Assert.Equal(2, result.Value.TotalItemCount);
}
[Fact]
public async Task Handle_UsernameSearch_ReturnsOnlyMatches()
{
await SeedAsync(TestEntities.User(1, "alice-wonderland"), TestEntities.User(2, "bob-builder"));
var result = await CreateHandler().Handle(new GetUsersQuery(PageNumber: 1, PageSize: 10, UsernameSearch: "alice"), TestContext.Current.CancellationToken);
Assert.False(result.IsError);
var user = Assert.Single(result.Value.Items);
Assert.Equal(1, user.Id);
}
}
}