Files
Musify/backend/Tests/Musify.Application.Tests/Users/GetUserByIdQueryHandlerTests.cs
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

33 lines
1004 B
C#

using ErrorOr;
using Musify.Application.Tests.TestSupport;
using Musify.Application.Users;
using Xunit;
namespace Musify.Application.Tests.Users
{
public sealed class GetUserByIdQueryHandlerTests : HandlerTestBase
{
private GetUserByIdQueryHandler CreateHandler() => new(Database);
[Fact]
public async Task Handle_ExistingUser_ReturnsIt()
{
var user = TestEntities.User(1, "Jane Doe");
await SeedAsync(user);
var result = await CreateHandler().Handle(new GetUserByIdQuery(1), TestContext.Current.CancellationToken);
Assert.False(result.IsError);
Assert.Equal("Jane Doe", result.Value.Name);
}
[Fact]
public async Task Handle_UserMissing_ReturnsNotFound()
{
var result = await CreateHandler().Handle(new GetUserByIdQuery(404), TestContext.Current.CancellationToken);
Assert.Equal(ErrorType.NotFound, result.FirstError.Type);
}
}
}