Implements tests for commit 2e9f7d8496

This commit is contained in:
BinaryAlley committed 2026-10-28 23:50:00 +02:00
1 parent a75447062f
commit 468f1846f1
18 files changed
+1711 -48

No files matched your search

@@ -3,6 +3,7 @@ using Lumina.Application.Common.Mapping.UsersManagement.Users;
using Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSettings;
using Lumina.Contracts.Fixtures.Core.Requests.UsersManagement.Settings;
using Lumina.Contracts.Requests.UsersManagement.Settings;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -27,7 +28,19 @@ public class UpdateUserSettingsRequestMappingTests
isThemeCachingEnabled: true,
shouldAggregateMetadataWhenMissing: false,
shouldRenderPdfAsImages: true,
shouldPreserveBookStyles: true
shouldPreserveBookStyles: true,
shouldKeepDownloadingWhilePaused: false,
shouldAutoplay: false,
isGaplessPlaybackEnabled: false,
vuMeterOrientation: VuMeterOrientation.Horizontal,
vuMeterSegmentCount: 20,
vuMeterSegmentGap: 4,
vuMeterMediumThreshold: 0.35,
vuMeterHighThreshold: 0.9,
vuMeterShowPeak: false,
vuMeterPeakHoldDurationInMilliseconds: 1200,
vuMeterReleasePerSecond: 7.5,
vuMeterPeakReleasePerSecond: 0.25
);
// Act
@@ -41,5 +54,20 @@ public class UpdateUserSettingsRequestMappingTests
Assert.Equal(request.IsThemeCachingEnabled, result.IsThemeCachingEnabled);
Assert.Equal(request.ShouldRenderPdfAsImages, result.ShouldRenderPdfAsImages);
Assert.Equal(request.ShouldPreserveBookStyles, result.ShouldPreserveBookStyles);
Assert.Equal(request.ShouldKeepDownloadingWhilePaused, result.ShouldKeepDownloadingWhilePaused);
Assert.False(result.ShouldKeepDownloadingWhilePaused);
Assert.Equal(request.ShouldAutoplay, result.ShouldAutoplay);
Assert.False(result.ShouldAutoplay);
Assert.Equal(request.IsGaplessPlaybackEnabled, result.IsGaplessPlaybackEnabled);
Assert.False(result.IsGaplessPlaybackEnabled);
Assert.Equal(VuMeterOrientation.Horizontal, result.VuMeterOrientation);
Assert.Equal(20, result.VuMeterSegmentCount);
Assert.Equal(4, result.VuMeterSegmentGap);
Assert.Equal(0.35, result.VuMeterMediumThreshold);
Assert.Equal(0.9, result.VuMeterHighThreshold);
Assert.False(result.VuMeterShowPeak);
Assert.Equal(1200, result.VuMeterPeakHoldDurationInMilliseconds);
Assert.Equal(7.5, result.VuMeterReleasePerSecond);
Assert.Equal(0.25, result.VuMeterPeakReleasePerSecond);
}
}
@@ -801,6 +801,123 @@ public class ValidatorUtilitiesTests
result.ShouldNotHaveValidationError(s_equalValueError);
}
[Fact]
public void Validate_WhenNullableDoubleValueIsNull_ShouldNotHaveValidationError()
{
// Arrange
ValidatorUtilitiesTestRequest request = _validatorUtilitiesTestRequestFixture.Create(includeNullableDoubleValue: false);
// Act
List<Error> result = _validator.TestValidate(request);
// Assert
result.ShouldNotHaveValidationError(s_nullableDoubleValueError);
}
[Fact]
public void Validate_WhenNullableDoubleComparisonValueIsNull_ShouldNotHaveValidationError()
{
// Arrange
ValidatorUtilitiesTestRequest request = _validatorUtilitiesTestRequestFixture.Create(includeNullableDoubleComparisonValue: false);
// Act
List<Error> result = _validator.TestValidate(request);
// Assert
result.ShouldNotHaveValidationError(s_nullableDoubleValueError);
}
[Fact]
public void Validate_WhenNullableDoubleValueIsGreaterThanComparison_ShouldNotHaveValidationError()
{
// Arrange
ValidatorUtilitiesTestRequest request = _validatorUtilitiesTestRequestFixture.Create(
nullableDoubleValue: 6.0,
nullableDoubleComparisonValue: 5.0);
// Act
List<Error> result = _validator.TestValidate(request);
// Assert
result.ShouldNotHaveValidationError(s_nullableDoubleValueError);
}
[Fact]
public void Validate_WhenNullableDoubleValueEqualsComparison_ShouldNotHaveValidationError()
{
// Arrange
ValidatorUtilitiesTestRequest request = _validatorUtilitiesTestRequestFixture.Create(
nullableDoubleValue: 5.0,
nullableDoubleComparisonValue: 5.0);
// Act
List<Error> result = _validator.TestValidate(request);
// Assert
result.ShouldNotHaveValidationError(s_nullableDoubleValueError);
}
[Fact]
public void Validate_WhenNullableDoubleValueIsSmallerThanComparison_ShouldHaveValidationError()
{
// Arrange
ValidatorUtilitiesTestRequest request = _validatorUtilitiesTestRequestFixture.Create(
nullableDoubleValue: 4.0,
nullableDoubleComparisonValue: 5.0);
// Act
List<Error> result = _validator.TestValidate(request);
// Assert
result.ShouldHaveValidationError(s_nullableDoubleValueError);
}
[Fact]
public void Validate_WhenInclusiveNullableDoubleValueIsNull_ShouldNotHaveValidationError()
{
// Arrange
ValidatorUtilitiesTestRequest request = _validatorUtilitiesTestRequestFixture.Create(includeInclusiveNullableDoubleValue: false);
// Act
List<Error> result = _validator.TestValidate(request);
// Assert
result.ShouldNotHaveValidationError(s_inclusiveNullableDoubleValueError);
}
[Theory]
[InlineData(0.99)] // just below the minimum
[InlineData(10.01)] // just above the maximum
public void Validate_WhenInclusiveNullableDoubleValueIsOutsideRange_ShouldHaveValidationError(double inclusiveNullableDoubleValue)
{
// Arrange
ValidatorUtilitiesTestRequest request = _validatorUtilitiesTestRequestFixture.Create(
inclusiveNullableDoubleValue: inclusiveNullableDoubleValue);
// Act
List<Error> result = _validator.TestValidate(request);
// Assert
result.ShouldHaveValidationError(s_inclusiveNullableDoubleValueError);
}
[Theory]
[InlineData(1.0)] // the minimum
[InlineData(5.0)] // a middle value
[InlineData(10.0)] // the maximum
public void Validate_WhenInclusiveNullableDoubleValueIsWithinRange_ShouldNotHaveValidationError(double inclusiveNullableDoubleValue)
{
// Arrange
ValidatorUtilitiesTestRequest request = _validatorUtilitiesTestRequestFixture.Create(
inclusiveNullableDoubleValue: inclusiveNullableDoubleValue);
// Act
List<Error> result = _validator.TestValidate(request);
// Assert
result.ShouldNotHaveValidationError(s_inclusiveNullableDoubleValueError);
}
[ExcludeFromCodeCoverage]
private sealed class ValidatorUtilitiesTestValidator : AbstractValidator<ValidatorUtilitiesTestRequest>
{
@@ -829,6 +946,8 @@ public class ValidatorUtilitiesTests
RuleFor(request => request.SelectorMatchValue).Matches(instance => instance.PatternValue).WithError(s_selectorMatchValueError);
RuleFor(request => request.InclusiveIntValue).InclusiveBetween(1, 10).WithError(s_inclusiveIntValueError);
RuleFor(request => request.InclusiveNullableIntValue).InclusiveBetween(1, 10).WithError(s_inclusiveNullableIntValueError);
RuleFor(request => request.NullableDoubleValue).GreaterThanOrEqualTo(instance => instance.NullableDoubleComparisonValue).WithError(s_nullableDoubleValueError);
RuleFor(request => request.InclusiveNullableDoubleValue).InclusiveBetween(1d, 10d).WithError(s_inclusiveNullableDoubleValueError);
RuleFor(request => request.EqualValue).Equal(instance => instance.EqualComparisonValue).WithError(s_equalValueError);
}
}
@@ -856,5 +975,7 @@ public class ValidatorUtilitiesTests
private static readonly Error s_selectorMatchValueError = Error.Validation(description: "SelectorMatchValueError");
private static readonly Error s_inclusiveIntValueError = Error.Validation(description: "InclusiveIntValueError");
private static readonly Error s_inclusiveNullableIntValueError = Error.Validation(description: "InclusiveNullableIntValueError");
private static readonly Error s_nullableDoubleValueError = Error.Validation(description: "NullableDoubleValueError");
private static readonly Error s_inclusiveNullableDoubleValueError = Error.Validation(description: "InclusiveNullableDoubleValueError");
private static readonly Error s_equalValueError = Error.Validation(description: "EqualValueError");
}
@@ -77,7 +77,16 @@ public class UpdateUserSettingsCommandHandlerTests
settings.ItemsPerPage == command.ItemsPerPage &&
settings.ShouldIgnoreThePrefixForAlphaPicker == command.ShouldIgnoreThePrefixForAlphaPicker &&
settings.ShouldRenderPdfAsImages == command.ShouldRenderPdfAsImages &&
settings.ShouldPreserveBookStyles == command.ShouldPreserveBookStyles),
settings.ShouldPreserveBookStyles == command.ShouldPreserveBookStyles &&
settings.VuMeterOrientation == command.VuMeterOrientation &&
settings.VuMeterSegmentCount == command.VuMeterSegmentCount &&
settings.VuMeterSegmentGap == command.VuMeterSegmentGap &&
settings.VuMeterMediumThreshold == command.VuMeterMediumThreshold &&
settings.VuMeterHighThreshold == command.VuMeterHighThreshold &&
settings.VuMeterShowPeak == command.VuMeterShowPeak &&
settings.VuMeterPeakHoldDurationInMilliseconds == command.VuMeterPeakHoldDurationInMilliseconds &&
settings.VuMeterReleasePerSecond == command.VuMeterReleasePerSecond &&
settings.VuMeterPeakReleasePerSecond == command.VuMeterPeakReleasePerSecond),
Arg.Any<CancellationToken>());
await _mockUserSettingsRepository.DidNotReceive().UpdateAsync(Arg.Any<UserSettingsEntity>(), Arg.Any<CancellationToken>());
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
@@ -107,7 +116,16 @@ public class UpdateUserSettingsCommandHandlerTests
settings.ItemsPerPage == command.ItemsPerPage &&
settings.ShouldIgnoreThePrefixForAlphaPicker == command.ShouldIgnoreThePrefixForAlphaPicker &&
settings.ShouldRenderPdfAsImages == command.ShouldRenderPdfAsImages &&
settings.ShouldPreserveBookStyles == command.ShouldPreserveBookStyles),
settings.ShouldPreserveBookStyles == command.ShouldPreserveBookStyles &&
settings.VuMeterOrientation == command.VuMeterOrientation &&
settings.VuMeterSegmentCount == command.VuMeterSegmentCount &&
settings.VuMeterSegmentGap == command.VuMeterSegmentGap &&
settings.VuMeterMediumThreshold == command.VuMeterMediumThreshold &&
settings.VuMeterHighThreshold == command.VuMeterHighThreshold &&
settings.VuMeterShowPeak == command.VuMeterShowPeak &&
settings.VuMeterPeakHoldDurationInMilliseconds == command.VuMeterPeakHoldDurationInMilliseconds &&
settings.VuMeterReleasePerSecond == command.VuMeterReleasePerSecond &&
settings.VuMeterPeakReleasePerSecond == command.VuMeterPeakReleasePerSecond),
Arg.Any<CancellationToken>());
await _mockUserSettingsRepository.DidNotReceive().InsertAsync(Arg.Any<UserSettingsEntity>(), Arg.Any<CancellationToken>());
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any<CancellationToken>());
@@ -4,6 +4,7 @@ using Lumina.Application.Fixtures.Core.UsersManagement.Settings.Commands.UpdateU
using Lumina.Application.UnitTests.Common.Setup;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -51,6 +52,454 @@ public class UpdateUserSettingsCommandValidatorTests
result.ShouldNotHaveValidationError(Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero);
}
[Fact]
public void Validate_WhenVuMeterOrientationIsNull_ShouldHaveValidationError()
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(includeVuMeterOrientation: false);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterOrientationCannotBeNull);
}
[Fact]
public void Validate_WhenVuMeterSegmentCountIsNull_ShouldHaveValidationError()
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(includeVuMeterSegmentCount: false);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterSegmentCountCannotBeNull);
}
[Fact]
public void Validate_WhenVuMeterSegmentGapIsNull_ShouldHaveValidationError()
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(includeVuMeterSegmentGap: false);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterSegmentGapCannotBeNull);
}
[Fact]
public void Validate_WhenVuMeterMediumThresholdIsNull_ShouldHaveValidationError()
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(includeVuMeterMediumThreshold: false);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterMediumThresholdCannotBeNull);
}
[Fact]
public void Validate_WhenVuMeterHighThresholdIsNull_ShouldHaveValidationError()
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(includeVuMeterHighThreshold: false);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterHighThresholdCannotBeNull);
}
[Fact]
public void Validate_WhenVuMeterShowPeakIsNull_ShouldHaveValidationError()
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(includeVuMeterShowPeak: false);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterShowPeakCannotBeNull);
}
[Fact]
public void Validate_WhenVuMeterPeakHoldDurationIsNull_ShouldHaveValidationError()
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(includeVuMeterPeakHoldDurationInMilliseconds: false);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterPeakHoldDurationCannotBeNull);
}
[Fact]
public void Validate_WhenVuMeterReleasePerSecondIsNull_ShouldHaveValidationError()
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(includeVuMeterReleasePerSecond: false);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterReleasePerSecondCannotBeNull);
}
[Fact]
public void Validate_WhenVuMeterPeakReleasePerSecondIsNull_ShouldHaveValidationError()
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(includeVuMeterPeakReleasePerSecond: false);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterPeakReleasePerSecondCannotBeNull);
}
[Theory]
[InlineData(999)] // a value that is not a defined member of the enumeration
[InlineData(-1)] // a negative value that is not a defined member of the enumeration
public void Validate_WhenVuMeterOrientationIsNotDefined_ShouldHaveValidationError(int vuMeterOrientationValue)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(
vuMeterOrientation: (VuMeterOrientation)vuMeterOrientationValue);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.InvalidVuMeterOrientation);
}
[Theory]
[InlineData(VuMeterOrientation.Vertical)]
[InlineData(VuMeterOrientation.Horizontal)]
public void Validate_WhenVuMeterOrientationIsDefined_ShouldNotHaveValidationError(VuMeterOrientation vuMeterOrientation)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(vuMeterOrientation: vuMeterOrientation);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.UserSettings.InvalidVuMeterOrientation);
}
[Theory]
[InlineData(0)] // below the minimum
[InlineData(-1)] // negative
[InlineData(129)] // above the maximum
[InlineData(int.MaxValue)] // far above the maximum
public void Validate_WhenVuMeterSegmentCountIsOutOfRange_ShouldHaveValidationError(int vuMeterSegmentCount)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(vuMeterSegmentCount: vuMeterSegmentCount);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterSegmentCountMustBeBetweenOneAndOneHundredTwentyEight);
}
[Theory]
[InlineData(1)] // the minimum
[InlineData(64)] // a middle value
[InlineData(128)] // the maximum
public void Validate_WhenVuMeterSegmentCountIsInRange_ShouldNotHaveValidationError(int vuMeterSegmentCount)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(vuMeterSegmentCount: vuMeterSegmentCount);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.UserSettings.VuMeterSegmentCountMustBeBetweenOneAndOneHundredTwentyEight);
}
[Theory]
[InlineData(-1)] // below the minimum
[InlineData(33)] // above the maximum
[InlineData(int.MinValue)] // far below the minimum
public void Validate_WhenVuMeterSegmentGapIsOutOfRange_ShouldHaveValidationError(int vuMeterSegmentGap)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(vuMeterSegmentGap: vuMeterSegmentGap);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterSegmentGapMustBeBetweenZeroAndThirtyTwo);
}
[Theory]
[InlineData(0)] // the minimum
[InlineData(16)] // a middle value
[InlineData(32)] // the maximum
public void Validate_WhenVuMeterSegmentGapIsInRange_ShouldNotHaveValidationError(int vuMeterSegmentGap)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(vuMeterSegmentGap: vuMeterSegmentGap);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.UserSettings.VuMeterSegmentGapMustBeBetweenZeroAndThirtyTwo);
}
[Theory]
[InlineData(-0.01)] // just below the minimum
[InlineData(1.01)] // just above the maximum
[InlineData(double.MinValue)] // far below the minimum
public void Validate_WhenVuMeterMediumThresholdIsOutOfRange_ShouldHaveValidationError(double vuMeterMediumThreshold)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(
vuMeterMediumThreshold: vuMeterMediumThreshold,
vuMeterHighThreshold: 1.0);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterMediumThresholdMustBeBetweenZeroAndOne);
}
[Theory]
[InlineData(0.0)] // the minimum
[InlineData(0.5)] // a middle value
[InlineData(1.0)] // the maximum
public void Validate_WhenVuMeterMediumThresholdIsInRange_ShouldNotHaveValidationError(double vuMeterMediumThreshold)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(
vuMeterMediumThreshold: vuMeterMediumThreshold,
vuMeterHighThreshold: 1.0);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.UserSettings.VuMeterMediumThresholdMustBeBetweenZeroAndOne);
}
[Theory]
[InlineData(-0.01)] // just below the minimum
[InlineData(1.01)] // just above the maximum
[InlineData(double.MaxValue)] // far above the maximum
public void Validate_WhenVuMeterHighThresholdIsOutOfRange_ShouldHaveValidationError(double vuMeterHighThreshold)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(
vuMeterMediumThreshold: 0.0,
vuMeterHighThreshold: vuMeterHighThreshold);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterHighThresholdMustBeBetweenZeroAndOne);
}
[Fact]
public void Validate_WhenVuMeterHighThresholdIsAtTheMinimum_ShouldNotHaveValidationError()
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(
vuMeterMediumThreshold: 0.0,
vuMeterHighThreshold: 0.0);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.UserSettings.VuMeterHighThresholdMustBeBetweenZeroAndOne);
}
[Fact]
public void Validate_WhenVuMeterHighThresholdIsAtTheMaximum_ShouldNotHaveValidationError()
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(
vuMeterMediumThreshold: 0.5,
vuMeterHighThreshold: 1.0);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.UserSettings.VuMeterHighThresholdMustBeBetweenZeroAndOne);
}
[Fact]
public void Validate_WhenVuMeterHighThresholdIsLowerThanMediumThreshold_ShouldHaveValidationError()
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(
vuMeterMediumThreshold: 0.9,
vuMeterHighThreshold: 0.1);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterHighThresholdMustBeGreaterThanOrEqualToMediumThreshold);
}
[Theory]
[InlineData(0.5, 0.5)] // the thresholds are equal
[InlineData(0.4, 0.9)] // the high threshold is greater than the medium one
public void Validate_WhenVuMeterHighThresholdIsGreaterThanOrEqualToMediumThreshold_ShouldNotHaveValidationError(
double vuMeterMediumThreshold,
double vuMeterHighThreshold)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(
vuMeterMediumThreshold: vuMeterMediumThreshold,
vuMeterHighThreshold: vuMeterHighThreshold);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.UserSettings.VuMeterHighThresholdMustBeGreaterThanOrEqualToMediumThreshold);
}
[Theory]
[InlineData(true)]
[InlineData(false)]
public void Validate_WhenVuMeterShowPeakIsSpecified_ShouldNotHaveValidationError(bool vuMeterShowPeak)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(vuMeterShowPeak: vuMeterShowPeak);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.UserSettings.VuMeterShowPeakCannotBeNull);
}
[Theory]
[InlineData(-1)] // below the minimum
[InlineData(10001)] // above the maximum
[InlineData(int.MinValue)] // far below the minimum
public void Validate_WhenVuMeterPeakHoldDurationIsOutOfRange_ShouldHaveValidationError(int vuMeterPeakHoldDurationInMilliseconds)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(
vuMeterPeakHoldDurationInMilliseconds: vuMeterPeakHoldDurationInMilliseconds);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterPeakHoldDurationMustBeBetweenZeroAndTenThousandMilliseconds);
}
[Theory]
[InlineData(0)] // the minimum
[InlineData(650)] // a middle value
[InlineData(10000)] // the maximum
public void Validate_WhenVuMeterPeakHoldDurationIsInRange_ShouldNotHaveValidationError(int vuMeterPeakHoldDurationInMilliseconds)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(
vuMeterPeakHoldDurationInMilliseconds: vuMeterPeakHoldDurationInMilliseconds);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.UserSettings.VuMeterPeakHoldDurationMustBeBetweenZeroAndTenThousandMilliseconds);
}
[Theory]
[InlineData(-0.01)] // just below the minimum
[InlineData(100.01)] // just above the maximum
[InlineData(double.MinValue)] // far below the minimum
public void Validate_WhenVuMeterReleasePerSecondIsOutOfRange_ShouldHaveValidationError(double vuMeterReleasePerSecond)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(
vuMeterReleasePerSecond: vuMeterReleasePerSecond);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterReleasePerSecondMustBeBetweenZeroAndOneHundred);
}
[Theory]
[InlineData(0.0)] // the minimum
[InlineData(3.0)] // a middle value
[InlineData(100.0)] // the maximum
public void Validate_WhenVuMeterReleasePerSecondIsInRange_ShouldNotHaveValidationError(double vuMeterReleasePerSecond)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(
vuMeterReleasePerSecond: vuMeterReleasePerSecond);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.UserSettings.VuMeterReleasePerSecondMustBeBetweenZeroAndOneHundred);
}
[Theory]
[InlineData(-0.01)] // just below the minimum
[InlineData(100.01)] // just above the maximum
[InlineData(double.MaxValue)] // far above the maximum
public void Validate_WhenVuMeterPeakReleasePerSecondIsOutOfRange_ShouldHaveValidationError(double vuMeterPeakReleasePerSecond)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(
vuMeterPeakReleasePerSecond: vuMeterPeakReleasePerSecond);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationError(Errors.UserSettings.VuMeterPeakReleasePerSecondMustBeBetweenZeroAndOneHundred);
}
[Theory]
[InlineData(0.0)] // the minimum
[InlineData(0.65)] // a middle value
[InlineData(100.0)] // the maximum
public void Validate_WhenVuMeterPeakReleasePerSecondIsInRange_ShouldNotHaveValidationError(double vuMeterPeakReleasePerSecond)
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(
vuMeterPeakReleasePerSecond: vuMeterPeakReleasePerSecond);
// Act
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationError(Errors.UserSettings.VuMeterPeakReleasePerSecondMustBeBetweenZeroAndOneHundred);
}
[Fact]
public void Validate_WhenCommandIsValid_ShouldNotHaveAnyValidationError()
{