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).
53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using Musify.Api.DataTransferObjects.Users;
|
|
using Musify.Api.Validators.Users;
|
|
using Xunit;
|
|
|
|
namespace Musify.Api.Tests.Validators
|
|
{
|
|
public sealed class CreateUserRequestValidatorTests
|
|
{
|
|
private readonly CreateUserRequestValidator validator = new();
|
|
|
|
[Fact]
|
|
public void Validate_ValidRequest_Passes()
|
|
{
|
|
var result = validator.Validate(new CreateUserRequest(1, "Jane Doe", "Jane", "Doe"));
|
|
|
|
Assert.True(result.IsValid);
|
|
}
|
|
|
|
[Fact]
|
|
public void Validate_ZeroId_Fails()
|
|
{
|
|
var result = validator.Validate(new CreateUserRequest(0, "Jane Doe", null, null));
|
|
|
|
Assert.False(result.IsValid);
|
|
Assert.Contains(result.Errors, e => e.PropertyName == nameof(CreateUserRequest.Id));
|
|
}
|
|
|
|
[Fact]
|
|
public void Validate_BlankName_Fails()
|
|
{
|
|
var result = validator.Validate(new CreateUserRequest(1, "", null, null));
|
|
|
|
Assert.False(result.IsValid);
|
|
}
|
|
|
|
[Fact]
|
|
public void Validate_NameOverMaxLength_Fails()
|
|
{
|
|
var result = validator.Validate(new CreateUserRequest(1, new string('a', 49), null, null));
|
|
|
|
Assert.False(result.IsValid);
|
|
}
|
|
|
|
[Fact]
|
|
public void Validate_OptionalNamesOmitted_Passes()
|
|
{
|
|
var result = validator.Validate(new CreateUserRequest(1, "Jane Doe", null, null));
|
|
|
|
Assert.True(result.IsValid);
|
|
}
|
|
}
|
|
}
|