Implements tests for commit b2d274f609

This commit is contained in:
BinaryAlley committed 2026-10-27 17:32:37 +02:00
1 parent d185c77999
commit 5c436fc13d
17 files changed
+2261 -6

No files matched your search

@@ -459,4 +459,153 @@ public class AddLibraryCommandHandlerTests
await _mockLibraryRepository.DidNotReceive().InsertAsync(Arg.Any<LibraryEntity>(), Arg.Any<CancellationToken>());
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenProgressTrackingIsNotSpecifiedAndLibraryTypeTracksByDefault_ShouldUseTheTypeDefaults()
{
// Arrange
AddLibraryCommand command = _addLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.EBook),
shouldTrackConsumptionProgress: null,
completionThresholdPercentage: null);
LibraryEntity persistedLibrary = _libraryEntityFixture.Create(userId: _userId);
_mockLibraryRepository.GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>())
.Returns(Result.From<LibraryEntity?>(persistedLibrary));
// Act
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.False(result.IsFailure);
await _mockLibraryRepository.Received(1).InsertAsync(
Arg.Is<LibraryEntity>(library =>
library.LibraryType == LibraryType.EBook &&
library.ShouldTrackConsumptionProgress &&
library.CompletionThresholdPercentage == 100),
Arg.Any<CancellationToken>());
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenProgressTrackingIsNotSpecifiedAndLibraryTypeDoesNotTrackByDefault_ShouldStoreTrackingOffWithoutThreshold()
{
// Arrange
AddLibraryCommand command = _addLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Music),
shouldTrackConsumptionProgress: null,
completionThresholdPercentage: null);
LibraryEntity persistedLibrary = _libraryEntityFixture.Create(userId: _userId);
_mockLibraryRepository.GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>())
.Returns(Result.From<LibraryEntity?>(persistedLibrary));
// Act
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.False(result.IsFailure);
await _mockLibraryRepository.Received(1).InsertAsync(
Arg.Is<LibraryEntity>(library =>
library.LibraryType == LibraryType.Music &&
!library.ShouldTrackConsumptionProgress &&
library.CompletionThresholdPercentage == null),
Arg.Any<CancellationToken>());
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenProgressTrackingIsExplicitlyEnabledOnATypeWithoutDefaultThreshold_ShouldStoreTrackingOnWithoutThreshold()
{
// Arrange
AddLibraryCommand command = _addLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Music),
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: null);
LibraryEntity persistedLibrary = _libraryEntityFixture.Create(userId: _userId);
_mockLibraryRepository.GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>())
.Returns(Result.From<LibraryEntity?>(persistedLibrary));
// Act
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.False(result.IsFailure);
await _mockLibraryRepository.Received(1).InsertAsync(
Arg.Is<LibraryEntity>(library =>
library.LibraryType == LibraryType.Music &&
library.ShouldTrackConsumptionProgress &&
library.CompletionThresholdPercentage == null),
Arg.Any<CancellationToken>());
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenExplicitThresholdIsSuppliedWhileProgressTrackingIsEnabled_ShouldStoreTheSuppliedThreshold()
{
// Arrange
AddLibraryCommand command = _addLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: 42);
LibraryEntity persistedLibrary = _libraryEntityFixture.Create(userId: _userId);
_mockLibraryRepository.GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>())
.Returns(Result.From<LibraryEntity?>(persistedLibrary));
// Act
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.False(result.IsFailure);
await _mockLibraryRepository.Received(1).InsertAsync(
Arg.Is<LibraryEntity>(library =>
library.LibraryType == LibraryType.Book &&
library.ShouldTrackConsumptionProgress &&
library.CompletionThresholdPercentage == 42),
Arg.Any<CancellationToken>());
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenProgressTrackingIsExplicitlyDisabledWithoutThreshold_ShouldStoreTrackingOffWithoutThreshold()
{
// Arrange
AddLibraryCommand command = _addLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: false,
completionThresholdPercentage: null);
LibraryEntity persistedLibrary = _libraryEntityFixture.Create(userId: _userId);
_mockLibraryRepository.GetByIdAsync(Arg.Any<Guid>(), cancellationToken: Arg.Any<CancellationToken>())
.Returns(Result.From<LibraryEntity?>(persistedLibrary));
// Act
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.False(result.IsFailure);
await _mockLibraryRepository.Received(1).InsertAsync(
Arg.Is<LibraryEntity>(library =>
library.LibraryType == LibraryType.Book &&
!library.ShouldTrackConsumptionProgress &&
library.CompletionThresholdPercentage == null),
Arg.Any<CancellationToken>());
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenProgressTrackingIsExplicitlyDisabledButThresholdIsSupplied_ShouldReturnThresholdMustBeNullError()
{
// Arrange
AddLibraryCommand command = _addLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: false,
completionThresholdPercentage: 50);
// Act
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.True(result.IsFailure);
Assert.Equal(DomainErrors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff, result.FirstError);
await _mockLibraryRepository.DidNotReceive().InsertAsync(Arg.Any<LibraryEntity>(), Arg.Any<CancellationToken>());
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
}
}
@@ -303,4 +303,109 @@ public class AddLibraryCommandValidatorTests
// Assert
result.ShouldNotHaveAnyValidationErrors();
}
[Theory]
[InlineData(-1)] // just below the allowed range
[InlineData(int.MinValue)] // the lowest possible value
public void Validate_WhenThresholdIsBelowZero_ShouldHaveValidationError(int completionThresholdPercentage)
{
// Arrange
AddLibraryCommand command = _addLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: completionThresholdPercentage);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred);
}
[Theory]
[InlineData(101)] // just above the allowed range
[InlineData(int.MaxValue)] // the highest possible value
public void Validate_WhenThresholdIsAboveOneHundred_ShouldHaveValidationError(int completionThresholdPercentage)
{
// Arrange
AddLibraryCommand command = _addLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: completionThresholdPercentage);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred);
}
[Theory]
[InlineData(0)] // the lowest allowed boundary
[InlineData(100)] // the highest allowed boundary
public void Validate_WhenThresholdIsAtAnAllowedBoundary_ShouldNotHaveValidationError(int completionThresholdPercentage)
{
// Arrange
AddLibraryCommand command = _addLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: completionThresholdPercentage);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred);
result.ShouldNotHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff);
}
[Fact]
public void Validate_WhenThresholdIsSuppliedWhileProgressTrackingIsDisabled_ShouldHaveValidationError()
{
// Arrange
AddLibraryCommand command = _addLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: false,
completionThresholdPercentage: 50);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff);
}
[Fact]
public void Validate_WhenThresholdIsSuppliedWhileProgressTrackingIsNotSpecified_ShouldNotHaveValidationError()
{
// Arrange
AddLibraryCommand command = _addLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: null,
completionThresholdPercentage: 50);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff);
result.ShouldNotHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred);
}
[Fact]
public void Validate_WhenProgressTrackingIsDisabledWithoutThreshold_ShouldNotHaveValidationError()
{
// Arrange
AddLibraryCommand command = _addLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: false,
completionThresholdPercentage: null);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff);
result.ShouldNotHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred);
}
}
@@ -600,4 +600,211 @@ public class UpdateLibraryCommandHandlerTests
await _mockLibraryRepository.DidNotReceive().UpdateAsync(Arg.Any<LibraryEntity>(), Arg.Any<CancellationToken>());
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenConsumptionSettingsAreNotSpecified_ShouldKeepTheStoredSettings()
{
// Arrange
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: null,
completionThresholdPercentage: null);
LibraryEntity existingLibrary = _libraryEntityFixture.Create(
id: command.Id,
userId: command.OwnerId,
libraryType: LibraryType.Book,
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: 80);
_mockLibraryRepository.GetByIdAsync(command.Id, cancellationToken: Arg.Any<CancellationToken>())
.Returns(Result.From<LibraryEntity?>(existingLibrary));
// Act
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.False(result.IsFailure);
await _mockLibraryRepository.Received(1).UpdateAsync(
Arg.Is<LibraryEntity>(library =>
library.ShouldTrackConsumptionProgress &&
library.CompletionThresholdPercentage == 80),
Arg.Any<CancellationToken>());
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenThresholdIsSuppliedWhileTrackingStaysEnabled_ShouldStoreTheSuppliedThreshold()
{
// Arrange
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: null,
completionThresholdPercentage: 60);
LibraryEntity existingLibrary = _libraryEntityFixture.Create(
id: command.Id,
userId: command.OwnerId,
libraryType: LibraryType.Book,
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: 80);
_mockLibraryRepository.GetByIdAsync(command.Id, cancellationToken: Arg.Any<CancellationToken>())
.Returns(Result.From<LibraryEntity?>(existingLibrary));
// Act
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.False(result.IsFailure);
await _mockLibraryRepository.Received(1).UpdateAsync(
Arg.Is<LibraryEntity>(library =>
library.ShouldTrackConsumptionProgress &&
library.CompletionThresholdPercentage == 60),
Arg.Any<CancellationToken>());
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenProgressTrackingIsDisabled_ShouldDropTheStoredThreshold()
{
// Arrange
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: false,
completionThresholdPercentage: null);
LibraryEntity existingLibrary = _libraryEntityFixture.Create(
id: command.Id,
userId: command.OwnerId,
libraryType: LibraryType.Book,
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: 80);
_mockLibraryRepository.GetByIdAsync(command.Id, cancellationToken: Arg.Any<CancellationToken>())
.Returns(Result.From<LibraryEntity?>(existingLibrary));
// Act
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.False(result.IsFailure);
await _mockLibraryRepository.Received(1).UpdateAsync(
Arg.Is<LibraryEntity>(library =>
!library.ShouldTrackConsumptionProgress &&
library.CompletionThresholdPercentage == null),
Arg.Any<CancellationToken>());
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenProgressTrackingIsExplicitlyDisabledButThresholdIsSupplied_ShouldReturnThresholdMustBeNullError()
{
// Arrange
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: false,
completionThresholdPercentage: 50);
LibraryEntity existingLibrary = _libraryEntityFixture.Create(
id: command.Id,
userId: command.OwnerId,
libraryType: LibraryType.Book,
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: 80);
_mockLibraryRepository.GetByIdAsync(command.Id, cancellationToken: Arg.Any<CancellationToken>())
.Returns(Result.From<LibraryEntity?>(existingLibrary));
// Act
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.True(result.IsFailure);
Assert.Equal(DomainErrors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff, result.FirstError);
await _mockLibraryRepository.DidNotReceive().UpdateAsync(Arg.Any<LibraryEntity>(), Arg.Any<CancellationToken>());
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenTrackingStaysEnabledWithoutThreshold_ShouldKeepTheStoredThresholdInsteadOfTheTypeDefault()
{
// Arrange
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: null);
LibraryEntity existingLibrary = _libraryEntityFixture.Create(
id: command.Id,
userId: command.OwnerId,
libraryType: LibraryType.Book,
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: 80);
_mockLibraryRepository.GetByIdAsync(command.Id, cancellationToken: Arg.Any<CancellationToken>())
.Returns(Result.From<LibraryEntity?>(existingLibrary));
// Act
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.False(result.IsFailure);
await _mockLibraryRepository.Received(1).UpdateAsync(
Arg.Is<LibraryEntity>(library =>
library.ShouldTrackConsumptionProgress &&
library.CompletionThresholdPercentage == 80),
Arg.Any<CancellationToken>());
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenTrackingIsEnabledWithoutThresholdAndTheLibraryTypeHasNoDefault_ShouldStoreTrackingOnWithoutThreshold()
{
// Arrange
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Music),
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: null);
LibraryEntity existingLibrary = _libraryEntityFixture.Create(
id: command.Id,
userId: command.OwnerId,
libraryType: LibraryType.Music,
shouldTrackConsumptionProgress: false,
completionThresholdPercentage: null);
_mockLibraryRepository.GetByIdAsync(command.Id, cancellationToken: Arg.Any<CancellationToken>())
.Returns(Result.From<LibraryEntity?>(existingLibrary));
// Act
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.False(result.IsFailure);
await _mockLibraryRepository.Received(1).UpdateAsync(
Arg.Is<LibraryEntity>(library =>
library.ShouldTrackConsumptionProgress &&
library.CompletionThresholdPercentage == null),
Arg.Any<CancellationToken>());
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenThresholdIsSuppliedWhileEnablingTracking_ShouldStoreTheSuppliedThreshold()
{
// Arrange
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Music),
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: 65);
LibraryEntity existingLibrary = _libraryEntityFixture.Create(
id: command.Id,
userId: command.OwnerId,
libraryType: LibraryType.Music,
shouldTrackConsumptionProgress: false,
completionThresholdPercentage: null);
_mockLibraryRepository.GetByIdAsync(command.Id, cancellationToken: Arg.Any<CancellationToken>())
.Returns(Result.From<LibraryEntity?>(existingLibrary));
// Act
Result<LibraryResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.False(result.IsFailure);
await _mockLibraryRepository.Received(1).UpdateAsync(
Arg.Is<LibraryEntity>(library =>
library.ShouldTrackConsumptionProgress &&
library.CompletionThresholdPercentage == 65),
Arg.Any<CancellationToken>());
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
}
}
@@ -358,4 +358,109 @@ public class UpdateLibraryCommandValidatorTests
// Assert
result.ShouldNotHaveAnyValidationErrors();
}
[Theory]
[InlineData(-1)] // just below the allowed range
[InlineData(int.MinValue)] // the lowest possible value
public void Validate_WhenThresholdIsBelowZero_ShouldHaveValidationError(int completionThresholdPercentage)
{
// Arrange
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: completionThresholdPercentage);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred);
}
[Theory]
[InlineData(101)] // just above the allowed range
[InlineData(int.MaxValue)] // the highest possible value
public void Validate_WhenThresholdIsAboveOneHundred_ShouldHaveValidationError(int completionThresholdPercentage)
{
// Arrange
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: completionThresholdPercentage);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred);
}
[Theory]
[InlineData(0)] // the lowest allowed boundary
[InlineData(100)] // the highest allowed boundary
public void Validate_WhenThresholdIsAtAnAllowedBoundary_ShouldNotHaveValidationError(int completionThresholdPercentage)
{
// Arrange
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: true,
completionThresholdPercentage: completionThresholdPercentage);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred);
result.ShouldNotHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff);
}
[Fact]
public void Validate_WhenThresholdIsSuppliedWhileProgressTrackingIsDisabled_ShouldHaveValidationError()
{
// Arrange
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: false,
completionThresholdPercentage: 50);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff);
}
[Fact]
public void Validate_WhenThresholdIsSuppliedWhileProgressTrackingIsNotSpecified_ShouldNotHaveValidationError()
{
// Arrange
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: null,
completionThresholdPercentage: 50);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff);
result.ShouldNotHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred);
}
[Fact]
public void Validate_WhenProgressTrackingIsDisabledWithoutThreshold_ShouldNotHaveValidationError()
{
// Arrange
UpdateLibraryCommand command = _updateLibraryCommandFixture.Create(
libraryType: nameof(LibraryType.Book),
shouldTrackConsumptionProgress: false,
completionThresholdPercentage: null);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff);
result.ShouldNotHaveValidationError(Errors.Library.CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred);
}
}