mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-15 01:54:43 +00:00
Add validator tests for brewery and user commands (#282)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using Features.Breweries.Commands.UpdateBrewery;
|
||||
using FluentValidation.TestHelper;
|
||||
|
||||
namespace Features.Breweries.Tests.Commands;
|
||||
|
||||
public class UpdateBreweryValidatorTests
|
||||
{
|
||||
private readonly UpdateBreweryValidator _validator = new();
|
||||
|
||||
private static UpdateBreweryCommand ValidCommand() =>
|
||||
new(Guid.NewGuid(), Guid.NewGuid(), [0x01, 0x02], "Name", "Description", null);
|
||||
|
||||
[Fact]
|
||||
public void Validate_ValidCommand_HasNoValidationErrors()
|
||||
{
|
||||
TestValidationResult<UpdateBreweryCommand> result = _validator.TestValidate(ValidCommand());
|
||||
|
||||
result.ShouldNotHaveAnyValidationErrors();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_EmptyRowVersion_HasErrorForRowVersion()
|
||||
{
|
||||
UpdateBreweryCommand command = ValidCommand() with { RowVersion = [] };
|
||||
|
||||
TestValidationResult<UpdateBreweryCommand> result = _validator.TestValidate(command);
|
||||
|
||||
result
|
||||
.ShouldHaveValidationErrorFor(x => x.RowVersion)
|
||||
.WithErrorMessage("RowVersion is required to detect conflicting concurrent updates.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user