Rename WebApi project to Vegasco.Server.Api
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
And update all references including comments etc.
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
using FluentAssertions;
|
||||
using FluentValidation.Results;
|
||||
using Vegasco.Server.Api.Cars;
|
||||
|
||||
namespace Vegasco.Server.Api.Tests.Unit.Cars;
|
||||
|
||||
public sealed class UpdateCarRequestValidatorTests
|
||||
{
|
||||
private readonly UpdateCar.Validator _sut = new();
|
||||
|
||||
private readonly UpdateCar.Request _validRequest = new("Ford Focus");
|
||||
|
||||
[Fact]
|
||||
public async Task ValidateAsync_ShouldBeValid_WhenRequestIsValid()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
// Act
|
||||
ValidationResult? result = await _sut.ValidateAsync(_validRequest);
|
||||
|
||||
// Assert
|
||||
result.IsValid.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(1)]
|
||||
[InlineData(50)]
|
||||
public async Task ValidateAsync_ShouldBeValid_WhenNameIsJustWithinTheLimits(int nameLength)
|
||||
{
|
||||
// Arrange
|
||||
UpdateCar.Request request = _validRequest with { Name = new string('s', nameLength) };
|
||||
|
||||
// Act
|
||||
ValidationResult? result = await _sut.ValidateAsync(request);
|
||||
|
||||
// Assert
|
||||
result.IsValid.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ValidateAsync_ShouldNotBeValid_WhenNameIsEmpty()
|
||||
{
|
||||
// Arrange
|
||||
UpdateCar.Request request = _validRequest with { Name = "" };
|
||||
|
||||
// Act
|
||||
ValidationResult? result = await _sut.ValidateAsync(request);
|
||||
|
||||
// Assert
|
||||
result.IsValid.Should().BeFalse();
|
||||
result.Errors.Should().ContainSingle()
|
||||
.Which
|
||||
.PropertyName.Should().Be(nameof(UpdateCar.Request.Name));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ValidateAsync_ShouldNotBeValid_WhenNameIsTooLong()
|
||||
{
|
||||
// Arrange
|
||||
const int nameMaxLength = 50;
|
||||
UpdateCar.Request request = _validRequest with { Name = new string('s', nameMaxLength + 1) };
|
||||
|
||||
// Act
|
||||
ValidationResult? result = await _sut.ValidateAsync(request);
|
||||
|
||||
// Assert
|
||||
result.IsValid.Should().BeFalse();
|
||||
result.Errors.Should().ContainSingle()
|
||||
.Which
|
||||
.PropertyName.Should().Be(nameof(UpdateCar.Request.Name));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user