From 96c3cb368e143cd31d8a1a5a82c333d15f8f39db Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Sat, 17 Aug 2024 09:33:20 -0500 Subject: [PATCH] style: Use collection expressions across whole solution --- .../Console/Commands/ConfigCreateCommand.cs | 2 +- .../Commands/DeleteCustomFormatsCommand.cs | 2 +- .../Console/Commands/SyncCommand.cs | 4 +- .../Steps/DeleteRepoDirMigrationStep.cs | 6 +- .../Migration/Steps/MoveOsxAppDataDotnet8.cs | 6 +- .../CustomFormatPipelineContext.cs | 6 +- .../MediaNaming/MediaNamingPipelineContext.cs | 6 +- .../QualityProfile/QualityItemOrganizer.cs | 10 +- .../QualityProfilePipelineContext.cs | 6 +- .../QualitySize/QualitySizePipelineContext.cs | 6 +- .../Delete/DeleteCustomFormatsProcessor.cs | 2 +- .../ConfigMerging/ServiceConfigMerger.cs | 2 +- src/Recyclarr.VersionControl/GitRepository.cs | 6 +- .../BaseCommandSetupIntegrationTest.cs | 5 +- .../ConfigCreationProcessorIntegrationTest.cs | 10 +- .../TemplateConfigCreatorIntegrationTest.cs | 10 +- .../Cache/CustomFormatCacheTest.cs | 35 ++-- .../Migration/MigrationExecutorTest.cs | 2 +- .../Models/CustomFormatDataComparerTest.cs | 156 ++++++++--------- .../Models/FieldsArrayJsonConverterTest.cs | 10 +- .../CustomFormatConfigPhaseTest.cs | 15 +- .../SonarrMediaNamingConfigPhaseTest.cs | 5 +- .../Api/QualityProfileDtoTest.cs | 6 +- .../QualityProfileConfigPhaseTest.cs | 93 +++++----- .../QualityProfileTransactionPhaseTest.cs | 159 +++++++++--------- .../QualityItemOrganizerTest.cs | 96 +++++------ .../QualityProfileExtensionsTest.cs | 5 +- .../UpdatedQualityProfileTest.cs | 6 +- .../UpdatedQualityProfileValidatorTest.cs | 14 +- .../QualitySizeConfigPhaseTest.cs | 42 ++--- .../Config/TemplateConfigCreatorTest.cs | 2 +- .../Processors/ConfigTemplateListerTest.cs | 5 +- .../BulkJsonLoaderIntegrationTest.cs | 14 +- .../ConfigurationLoaderEnvVarTest.cs | 30 ++-- .../ConfigurationRegistryTest.cs | 17 +- .../CustomFormatLoaderIntegrationTest.cs | 14 +- .../IncludePostProcessorIntegrationTest.cs | 44 ++--- .../QualitySizeGuideParserTest.cs | 15 +- .../Extensions/FileSystemExtensionsTest.cs | 25 ++- .../Config/ConfigExtensionsTest.cs | 4 +- .../Parsing/ConfigValidationExecutorTest.cs | 10 +- .../ConfigYamlDataObjectsValidationTest.cs | 60 +++---- .../ConfigMerging/MergeCustomFormatsTest.cs | 142 ++++++++-------- .../ConfigMerging/MergeQualityProfilesTest.cs | 84 ++++----- .../TemplateIncludeProcessorTest.cs | 15 +- .../Config/Parsing/YamlConfigValidatorTest.cs | 6 +- tests/Recyclarr.Tests/Json/JsonUtilsTest.cs | 6 +- .../CustomFormatCategoryParserTest.cs | 10 +- 48 files changed, 583 insertions(+), 653 deletions(-) diff --git a/src/Recyclarr.Cli/Console/Commands/ConfigCreateCommand.cs b/src/Recyclarr.Cli/Console/Commands/ConfigCreateCommand.cs index ebc8a059..dc0c405b 100644 --- a/src/Recyclarr.Cli/Console/Commands/ConfigCreateCommand.cs +++ b/src/Recyclarr.Cli/Console/Commands/ConfigCreateCommand.cs @@ -28,7 +28,7 @@ public class ConfigCreateCommand(ILogger log, IConfigCreationProcessor processor "One or more template configuration files to create. Use `config list templates` to get a list of " + "names accepted here.")] [UsedImplicitly(ImplicitUseKindFlags.Assign)] - public string[] TemplatesOption { get; init; } = Array.Empty(); + public string[] TemplatesOption { get; init; } = []; public IReadOnlyCollection Templates => TemplatesOption; [CommandOption("-f|--force")] diff --git a/src/Recyclarr.Cli/Console/Commands/DeleteCustomFormatsCommand.cs b/src/Recyclarr.Cli/Console/Commands/DeleteCustomFormatsCommand.cs index d0980725..e1be7afb 100644 --- a/src/Recyclarr.Cli/Console/Commands/DeleteCustomFormatsCommand.cs +++ b/src/Recyclarr.Cli/Console/Commands/DeleteCustomFormatsCommand.cs @@ -27,7 +27,7 @@ public class DeleteCustomFormatsCommand( [CommandArgument(0, "[cf_names]")] [Description("One or more custom format names to delete. Optional only if `--all` is used.")] - public string[] CustomFormatNamesOption { get; init; } = Array.Empty(); + public string[] CustomFormatNamesOption { get; init; } = []; public IReadOnlyCollection CustomFormatNames => CustomFormatNamesOption; [CommandOption("-a|--all")] diff --git a/src/Recyclarr.Cli/Console/Commands/SyncCommand.cs b/src/Recyclarr.Cli/Console/Commands/SyncCommand.cs index 69a59c7f..f69d10a5 100644 --- a/src/Recyclarr.Cli/Console/Commands/SyncCommand.cs +++ b/src/Recyclarr.Cli/Console/Commands/SyncCommand.cs @@ -29,7 +29,7 @@ public class SyncCommand(IMigrationExecutor migration, IMultiRepoUpdater repoUpd [CommandOption("-c|--config")] [Description("One or more YAML configuration files to load & use.")] [UsedImplicitly(ImplicitUseKindFlags.Assign)] - public string[] ConfigsOption { get; init; } = Array.Empty(); + public string[] ConfigsOption { get; init; } = []; public IReadOnlyCollection Configs => ConfigsOption; [CommandOption("-p|--preview")] @@ -40,7 +40,7 @@ public class SyncCommand(IMigrationExecutor migration, IMultiRepoUpdater repoUpd [CommandOption("-i|--instance")] [Description("One or more instance names to sync. If not specified, all instances will be synced.")] [UsedImplicitly(ImplicitUseKindFlags.Assign)] - public string[] InstancesOption { get; init; } = Array.Empty(); + public string[] InstancesOption { get; init; } = []; public IReadOnlyCollection Instances => InstancesOption; } diff --git a/src/Recyclarr.Cli/Migration/Steps/DeleteRepoDirMigrationStep.cs b/src/Recyclarr.Cli/Migration/Steps/DeleteRepoDirMigrationStep.cs index b55b6ccb..7573a415 100644 --- a/src/Recyclarr.Cli/Migration/Steps/DeleteRepoDirMigrationStep.cs +++ b/src/Recyclarr.Cli/Migration/Steps/DeleteRepoDirMigrationStep.cs @@ -9,11 +9,11 @@ namespace Recyclarr.Cli.Migration.Steps; public class DeleteRepoDirMigrationStep(IAppPaths paths) : IMigrationStep { public string Description => "Delete old repo directory"; - public IReadOnlyCollection Remediation => new[] - { + public IReadOnlyCollection Remediation => + [ $"Ensure Recyclarr has permission to recursively delete {RepoDir}", $"Delete {RepoDir} manually if Recyclarr can't do it" - }; + ]; public bool Required => false; private IDirectoryInfo RepoDir => paths.AppDataDirectory.SubDirectory("repo"); diff --git a/src/Recyclarr.Cli/Migration/Steps/MoveOsxAppDataDotnet8.cs b/src/Recyclarr.Cli/Migration/Steps/MoveOsxAppDataDotnet8.cs index 9038aad7..69d157ea 100644 --- a/src/Recyclarr.Cli/Migration/Steps/MoveOsxAppDataDotnet8.cs +++ b/src/Recyclarr.Cli/Migration/Steps/MoveOsxAppDataDotnet8.cs @@ -13,11 +13,11 @@ public class MoveOsxAppDataDotnet8( : IMigrationStep { public string Description => "Migrate OSX app data to 'Library/Application Support'"; - public IReadOnlyCollection Remediation => new[] - { + public IReadOnlyCollection Remediation => + [ $"Ensure Recyclarr has permission to move {OldAppDataDir} to {NewAppDataDir} and try again", $"Move {OldAppDataDir} to {NewAppDataDir} manually if Recyclarr can't do it" - }; + ]; public bool Required => true; diff --git a/src/Recyclarr.Cli/Pipelines/CustomFormat/CustomFormatPipelineContext.cs b/src/Recyclarr.Cli/Pipelines/CustomFormat/CustomFormatPipelineContext.cs index e93ae6fc..34e80bc8 100644 --- a/src/Recyclarr.Cli/Pipelines/CustomFormat/CustomFormatPipelineContext.cs +++ b/src/Recyclarr.Cli/Pipelines/CustomFormat/CustomFormatPipelineContext.cs @@ -9,11 +9,11 @@ namespace Recyclarr.Cli.Pipelines.CustomFormat; public class CustomFormatPipelineContext : IPipelineContext { public string PipelineDescription => "Custom Format"; - public IReadOnlyCollection SupportedServiceTypes { get; } = new[] - { + public IReadOnlyCollection SupportedServiceTypes { get; } = + [ SupportedServices.Sonarr, SupportedServices.Radarr - }; + ]; public IList ConfigOutput { get; init; } = []; public IList ApiFetchOutput { get; init; } = []; diff --git a/src/Recyclarr.Cli/Pipelines/MediaNaming/MediaNamingPipelineContext.cs b/src/Recyclarr.Cli/Pipelines/MediaNaming/MediaNamingPipelineContext.cs index b19fff2b..d4b8e41f 100644 --- a/src/Recyclarr.Cli/Pipelines/MediaNaming/MediaNamingPipelineContext.cs +++ b/src/Recyclarr.Cli/Pipelines/MediaNaming/MediaNamingPipelineContext.cs @@ -8,11 +8,11 @@ namespace Recyclarr.Cli.Pipelines.MediaNaming; public class MediaNamingPipelineContext : IPipelineContext { public string PipelineDescription => "Media Naming"; - public IReadOnlyCollection SupportedServiceTypes { get; } = new[] - { + public IReadOnlyCollection SupportedServiceTypes { get; } = + [ SupportedServices.Sonarr, SupportedServices.Radarr - }; + ]; public ProcessedNamingConfig ConfigOutput { get; set; } = default!; public MediaNamingDto ApiFetchOutput { get; set; } = default!; diff --git a/src/Recyclarr.Cli/Pipelines/QualityProfile/QualityItemOrganizer.cs b/src/Recyclarr.Cli/Pipelines/QualityProfile/QualityItemOrganizer.cs index 94510562..3d6e031f 100644 --- a/src/Recyclarr.Cli/Pipelines/QualityProfile/QualityItemOrganizer.cs +++ b/src/Recyclarr.Cli/Pipelines/QualityProfile/QualityItemOrganizer.cs @@ -7,7 +7,7 @@ namespace Recyclarr.Cli.Pipelines.QualityProfile; public class QualityItemOrganizer { - private readonly List _invalidItemNames = new(); + private readonly List _invalidItemNames = []; public UpdatedQualities OrganizeItems(QualityProfileDto dto, QualityProfileConfig config) { @@ -88,7 +88,7 @@ public class QualityItemOrganizer if (wantedItems.FindQualityByName(dto.Quality.Name) is null) { // Not in wanted list, so we keep - return new[] {dto}; + return [dto]; } } // Group @@ -106,15 +106,15 @@ public class QualityItemOrganizer } // If the group is NOT in the wanted list, keep the group and add its children (if they are not wanted) - return new[] - { + return + [ dto with { Items = unwantedQualities .Select(y => y with {Allowed = false}) .ToList() } - }; + ]; } return Array.Empty(); diff --git a/src/Recyclarr.Cli/Pipelines/QualityProfile/QualityProfilePipelineContext.cs b/src/Recyclarr.Cli/Pipelines/QualityProfile/QualityProfilePipelineContext.cs index 0fd29bf2..58a20c7a 100644 --- a/src/Recyclarr.Cli/Pipelines/QualityProfile/QualityProfilePipelineContext.cs +++ b/src/Recyclarr.Cli/Pipelines/QualityProfile/QualityProfilePipelineContext.cs @@ -11,11 +11,11 @@ namespace Recyclarr.Cli.Pipelines.QualityProfile; public class QualityProfilePipelineContext : IPipelineContext { public string PipelineDescription => "Quality Definition"; - public IReadOnlyCollection SupportedServiceTypes { get; } = new[] - { + public IReadOnlyCollection SupportedServiceTypes { get; } = + [ SupportedServices.Sonarr, SupportedServices.Radarr - }; + ]; public IList ConfigOutput { get; set; } = default!; public QualityProfileServiceData ApiFetchOutput { get; set; } = default!; diff --git a/src/Recyclarr.Cli/Pipelines/QualitySize/QualitySizePipelineContext.cs b/src/Recyclarr.Cli/Pipelines/QualitySize/QualitySizePipelineContext.cs index a2624b71..e7b9227c 100644 --- a/src/Recyclarr.Cli/Pipelines/QualitySize/QualitySizePipelineContext.cs +++ b/src/Recyclarr.Cli/Pipelines/QualitySize/QualitySizePipelineContext.cs @@ -11,11 +11,11 @@ namespace Recyclarr.Cli.Pipelines.QualitySize; public class QualitySizePipelineContext : IPipelineContext { public string PipelineDescription => "Quality Definition"; - public IReadOnlyCollection SupportedServiceTypes { get; } = new[] - { + public IReadOnlyCollection SupportedServiceTypes { get; } = + [ SupportedServices.Sonarr, SupportedServices.Radarr - }; + ]; public ProcessedQualitySizeData? ConfigOutput { get; set; } public IList ApiFetchOutput { get; set; } = default!; diff --git a/src/Recyclarr.Cli/Processors/Delete/DeleteCustomFormatsProcessor.cs b/src/Recyclarr.Cli/Processors/Delete/DeleteCustomFormatsProcessor.cs index af620eea..91436a59 100644 --- a/src/Recyclarr.Cli/Processors/Delete/DeleteCustomFormatsProcessor.cs +++ b/src/Recyclarr.Cli/Processors/Delete/DeleteCustomFormatsProcessor.cs @@ -158,7 +158,7 @@ public class DeleteCustomFormatsProcessor( { var configs = configRegistry.FindAndLoadConfigs(new ConfigFilterCriteria { - Instances = new[] {settings.InstanceName} + Instances = [settings.InstanceName] }); switch (configs.Count) diff --git a/src/Recyclarr.Config/Parsing/PostProcessing/ConfigMerging/ServiceConfigMerger.cs b/src/Recyclarr.Config/Parsing/PostProcessing/ConfigMerging/ServiceConfigMerger.cs index bec7f66a..5c689d8a 100644 --- a/src/Recyclarr.Config/Parsing/PostProcessing/ConfigMerging/ServiceConfigMerger.cs +++ b/src/Recyclarr.Config/Parsing/PostProcessing/ConfigMerging/ServiceConfigMerger.cs @@ -77,7 +77,7 @@ public abstract class ServiceConfigMerger where T : ServiceConfigYaml .Where(x => x.TrashIds is not null) .SelectMany(x => x is {AssignScoresTo.Count: > 0} ? x.AssignScoresTo.Select(y => new FlattenedCfs(y.Name, y.Score, x.TrashIds!)) - : new[] {new FlattenedCfs(null, null, x.TrashIds!)}) + : [new FlattenedCfs(null, null, x.TrashIds!)]) .GroupBy(x => (Name: x.ProfileName, x.Score)) .Select(x => new FlattenedCfs(x.Key.Name, x.Key.Score, x.SelectMany(y => y.TrashIds).ToList())) .ToList(); diff --git a/src/Recyclarr.VersionControl/GitRepository.cs b/src/Recyclarr.VersionControl/GitRepository.cs index a278d63f..257383a8 100644 --- a/src/Recyclarr.VersionControl/GitRepository.cs +++ b/src/Recyclarr.VersionControl/GitRepository.cs @@ -77,15 +77,15 @@ public sealed class GitRepository(ILogger log, IGitPath gitPath, IDirectoryInfo var args = new List {"clone"}; if (branch is not null) { - args.AddRange(new[] {"-b", branch}); + args.AddRange(["-b", branch]); } if (depth != 0) { - args.AddRange(new[] {"--depth", depth.ToString()}); + args.AddRange(["--depth", depth.ToString()]); } - args.AddRange(new[] {cloneUrl.ToString(), "."}); + args.AddRange([cloneUrl.ToString(), "."]); await RunGitCmd(token, args); } } diff --git a/tests/Recyclarr.Cli.IntegrationTests/BaseCommandSetupIntegrationTest.cs b/tests/Recyclarr.Cli.IntegrationTests/BaseCommandSetupIntegrationTest.cs index 9095e6ba..673ee96e 100644 --- a/tests/Recyclarr.Cli.IntegrationTests/BaseCommandSetupIntegrationTest.cs +++ b/tests/Recyclarr.Cli.IntegrationTests/BaseCommandSetupIntegrationTest.cs @@ -11,11 +11,10 @@ internal class BaseCommandSetupIntegrationTest : CliIntegrationFixture public void Base_command_startup_tasks_are_registered() { var registrations = Resolve>(); - registrations.Select(x => x.GetType()).Should().BeEquivalentTo(new[] - { + registrations.Select(x => x.GetType()).Should().BeEquivalentTo([ typeof(JanitorCleanupTask), typeof(ProgramInformationDisplayTask) - }); + ]); } [Test] diff --git a/tests/Recyclarr.Cli.IntegrationTests/ConfigCreationProcessorIntegrationTest.cs b/tests/Recyclarr.Cli.IntegrationTests/ConfigCreationProcessorIntegrationTest.cs index 3b5a567f..8bda3e0b 100644 --- a/tests/Recyclarr.Cli.IntegrationTests/ConfigCreationProcessorIntegrationTest.cs +++ b/tests/Recyclarr.Cli.IntegrationTests/ConfigCreationProcessorIntegrationTest.cs @@ -98,22 +98,20 @@ internal class ConfigCreationProcessorIntegrationTest : CliIntegrationFixture Fs.AddEmptyFile(repo.Path.File("template-file3.yml")); var settings = Substitute.For(); - settings.Templates.Returns(new[] - { + settings.Templates.Returns([ "template1", "template2", // This one shouldn't show up in the results because: // User specified it, but no template file exists for it. "template4" - }); + ]); var sut = Resolve(); sut.Process(settings); - Fs.AllFiles.Should().Contain(new[] - { + Fs.AllFiles.Should().Contain([ Paths.ConfigsDirectory.File("template-file1.yml").FullName, Paths.ConfigsDirectory.File("template-file2.yml").FullName - }); + ]); } } diff --git a/tests/Recyclarr.Cli.IntegrationTests/TemplateConfigCreatorIntegrationTest.cs b/tests/Recyclarr.Cli.IntegrationTests/TemplateConfigCreatorIntegrationTest.cs index 5a7617b4..47b03509 100644 --- a/tests/Recyclarr.Cli.IntegrationTests/TemplateConfigCreatorIntegrationTest.cs +++ b/tests/Recyclarr.Cli.IntegrationTests/TemplateConfigCreatorIntegrationTest.cs @@ -41,22 +41,20 @@ internal class TemplateConfigCreatorIntegrationTest : CliIntegrationFixture Fs.AddEmptyFile(repo.Path.File("template-file3.yml")); var settings = Substitute.For(); - settings.Templates.Returns(new[] - { + settings.Templates.Returns([ "template1", "template2", // This one shouldn't show up in the results because: // User specified it, but no template file exists for it. "template4" - }); + ]); var sut = Resolve(); sut.Create(settings); - Fs.AllFiles.Should().Contain(new[] - { + Fs.AllFiles.Should().Contain([ Paths.ConfigsDirectory.File("template-file1.yml").FullName, Paths.ConfigsDirectory.File("template-file2.yml").FullName - }); + ]); } } diff --git a/tests/Recyclarr.Cli.Tests/Cache/CustomFormatCacheTest.cs b/tests/Recyclarr.Cli.Tests/Cache/CustomFormatCacheTest.cs index c216d627..acdcb21f 100644 --- a/tests/Recyclarr.Cli.Tests/Cache/CustomFormatCacheTest.cs +++ b/tests/Recyclarr.Cli.Tests/Cache/CustomFormatCacheTest.cs @@ -31,13 +31,12 @@ public class CustomFormatCacheTest var cache = CfCache.New(); cache.Update(transactions); - cache.TrashIdMappings.Should().BeEquivalentTo(new[] - { + cache.TrashIdMappings.Should().BeEquivalentTo([ new TrashIdMapping("1", "one", 1), new TrashIdMapping("2", "two", 2), new TrashIdMapping("3", "three", 3), new TrashIdMapping("4", "four", 4) - }); + ]); } [Test] @@ -63,12 +62,11 @@ public class CustomFormatCacheTest cache.Update(transactions); - cache.TrashIdMappings.Should().BeEquivalentTo(new[] - { + cache.TrashIdMappings.Should().BeEquivalentTo([ new TrashIdMapping("1", "one", 1), new TrashIdMapping("2", "two", 2), new TrashIdMapping("4", "four", 4) - }); + ]); } [Test] @@ -89,11 +87,10 @@ public class CustomFormatCacheTest cache.RemoveStale(serviceCfs); - cache.TrashIdMappings.Should().BeEquivalentTo(new[] - { + cache.TrashIdMappings.Should().BeEquivalentTo([ new TrashIdMapping("1", "one", 1), new TrashIdMapping("2", "two", 2) - }); + ]); } [Test] @@ -116,11 +113,10 @@ public class CustomFormatCacheTest cache.Update(transactions); - cache.TrashIdMappings.Should().BeEquivalentTo(new[] - { + cache.TrashIdMappings.Should().BeEquivalentTo([ new TrashIdMapping("1", "one", 1), new TrashIdMapping("2", "two", 2) - }); + ]); } [Test] @@ -152,13 +148,12 @@ public class CustomFormatCacheTest cache.Update(transactions); - cache.TrashIdMappings.Should().BeEquivalentTo(new[] - { + cache.TrashIdMappings.Should().BeEquivalentTo([ new TrashIdMapping("1", "one_new", 1), new TrashIdMapping("2", "two_new", 2), new TrashIdMapping("3", "three_new", 3), new TrashIdMapping("4", "four_new", 4) - }); + ]); } [Test] @@ -176,13 +171,12 @@ public class CustomFormatCacheTest cache.Update(transactions); - cache.TrashIdMappings.Should().BeEquivalentTo(new[] - { + cache.TrashIdMappings.Should().BeEquivalentTo([ new TrashIdMapping("1", "one", 1), new TrashIdMapping("2", "two", 2), new TrashIdMapping("3", "three", 3), new TrashIdMapping("4", "four", 4) - }); + ]); } [Test] @@ -199,12 +193,11 @@ public class CustomFormatCacheTest cache.Update(transactions); - cache.TrashIdMappings.Should().BeEquivalentTo(new[] - { + cache.TrashIdMappings.Should().BeEquivalentTo([ new TrashIdMapping("1", "one", 1), new TrashIdMapping("2", "two", 2), new TrashIdMapping("3", "three", 3), new TrashIdMapping("4", "four", 4) - }, o => o.WithStrictOrdering()); + ], o => o.WithStrictOrdering()); } } diff --git a/tests/Recyclarr.Cli.Tests/Migration/MigrationExecutorTest.cs b/tests/Recyclarr.Cli.Tests/Migration/MigrationExecutorTest.cs index 0444dc2d..4a0f165d 100644 --- a/tests/Recyclarr.Cli.Tests/Migration/MigrationExecutorTest.cs +++ b/tests/Recyclarr.Cli.Tests/Migration/MigrationExecutorTest.cs @@ -87,7 +87,7 @@ public class MigrationExecutorTest using var console = new TestConsole(); var step = Substitute.For(); var executor = new MigrationExecutor(new[] {step}.AsOrdered(), console); - var exception = new MigrationException(new ArgumentException(), "a", new[] {"b"}); + var exception = new MigrationException(new ArgumentException(), "a", ["b"]); step.CheckIfNeeded().Returns(true); step.When(x => x.Execute(null)).Throw(exception); diff --git a/tests/Recyclarr.Cli.Tests/Pipelines/CustomFormat/Models/CustomFormatDataComparerTest.cs b/tests/Recyclarr.Cli.Tests/Pipelines/CustomFormat/Models/CustomFormatDataComparerTest.cs index cf87c6b6..5f83f2f6 100644 --- a/tests/Recyclarr.Cli.Tests/Pipelines/CustomFormat/Models/CustomFormatDataComparerTest.cs +++ b/tests/Recyclarr.Cli.Tests/Pipelines/CustomFormat/Models/CustomFormatDataComparerTest.cs @@ -12,21 +12,21 @@ public class CustomFormatDataComparerTest { Name = "EVO (no WEBDL)", IncludeCustomFormatWhenRenaming = false, - Specifications = new[] - { + Specifications = + [ new CustomFormatSpecificationData { Name = "EVO", Implementation = "ReleaseTitleSpecification", Negate = false, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = "\\bEVO(TGX)?\\b" } - } + ] }, new CustomFormatSpecificationData { @@ -34,13 +34,13 @@ public class CustomFormatDataComparerTest Implementation = "SourceSpecification", Negate = true, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = 7 } - } + ] }, new CustomFormatSpecificationData { @@ -48,36 +48,36 @@ public class CustomFormatDataComparerTest Implementation = "SourceSpecification", Negate = true, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = 8 } - } + ] } - } + ] }; var b = new CustomFormatData { Name = "EVO (no WEBDL)", IncludeCustomFormatWhenRenaming = false, - Specifications = new[] - { + Specifications = + [ new CustomFormatSpecificationData { Name = "EVO", Implementation = "ReleaseTitleSpecification", Negate = false, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = "\\bEVO(TGX)?\\b" } - } + ] }, new CustomFormatSpecificationData { @@ -85,13 +85,13 @@ public class CustomFormatDataComparerTest Implementation = "SourceSpecification", Negate = true, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = 7 } - } + ] }, new CustomFormatSpecificationData { @@ -99,15 +99,15 @@ public class CustomFormatDataComparerTest Implementation = "SourceSpecification", Negate = true, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = 8 } - } + ] } - } + ] }; a.Should().BeEquivalentTo(b, o => o.Using(CustomFormatData.Comparer)); @@ -120,21 +120,21 @@ public class CustomFormatDataComparerTest { Name = "EVO (no WEBDL)", IncludeCustomFormatWhenRenaming = false, - Specifications = new[] - { + Specifications = + [ new CustomFormatSpecificationData { Name = "EVO", Implementation = "ReleaseTitleSpecification", Negate = false, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = "\\bEVO(TGX)?\\b" } - } + ] }, new CustomFormatSpecificationData { @@ -142,13 +142,13 @@ public class CustomFormatDataComparerTest Implementation = "SourceSpecification", Negate = true, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = 7 } - } + ] }, new CustomFormatSpecificationData { @@ -156,36 +156,36 @@ public class CustomFormatDataComparerTest Implementation = "SourceSpecification", Negate = true, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = 8 } - } + ] } - } + ] }; var b = new CustomFormatData { Name = "EVO (no WEBDL)", IncludeCustomFormatWhenRenaming = false, - Specifications = new[] - { + Specifications = + [ new CustomFormatSpecificationData { Name = "EVO", Implementation = "ReleaseTitleSpecification", Negate = false, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = "\\bEVO(TGX)?\\b" } - } + ] }, new CustomFormatSpecificationData { @@ -193,13 +193,13 @@ public class CustomFormatDataComparerTest Implementation = "SourceSpecification", Negate = true, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = 10 // this is different } - } + ] }, new CustomFormatSpecificationData { @@ -207,15 +207,15 @@ public class CustomFormatDataComparerTest Implementation = "SourceSpecification", Negate = true, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = 8 } - } + ] } - } + ] }; var result = CustomFormatData.Comparer.Equals(a, b); @@ -284,23 +284,23 @@ public class CustomFormatDataComparerTest { Name = "EVO (no WEBDL)", IncludeCustomFormatWhenRenaming = false, - Specifications = new[] - { + Specifications = + [ new CustomFormatSpecificationData(), new CustomFormatSpecificationData() - } + ] }; var b = new CustomFormatData { Name = "EVO (no WEBDL)", IncludeCustomFormatWhenRenaming = false, - Specifications = new[] - { + Specifications = + [ new CustomFormatSpecificationData(), new CustomFormatSpecificationData(), new CustomFormatSpecificationData() - } + ] }; var result = CustomFormatData.Comparer.Equals(a, b); @@ -315,21 +315,21 @@ public class CustomFormatDataComparerTest { Name = "EVO (no WEBDL)", IncludeCustomFormatWhenRenaming = false, - Specifications = new[] - { + Specifications = + [ new CustomFormatSpecificationData { Name = "EVO", Implementation = "ReleaseTitleSpecification", Negate = false, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = "\\bEVO(TGX)?\\b" } - } + ] }, new CustomFormatSpecificationData { @@ -337,13 +337,13 @@ public class CustomFormatDataComparerTest Implementation = "SourceSpecification", Negate = true, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = 7 } - } + ] }, new CustomFormatSpecificationData { @@ -351,36 +351,36 @@ public class CustomFormatDataComparerTest Implementation = "SourceSpecification", Negate = true, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = 8 } - } + ] } - } + ] }; var b = new CustomFormatData { Name = "EVO (no WEBDL)", IncludeCustomFormatWhenRenaming = false, - Specifications = new[] - { + Specifications = + [ new CustomFormatSpecificationData { Name = "EVO", Implementation = "ReleaseTitleSpecification", Negate = false, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = "\\bEVO(TGX)?\\b" } - } + ] }, new CustomFormatSpecificationData { @@ -388,13 +388,13 @@ public class CustomFormatDataComparerTest Implementation = "SourceSpecification", Negate = true, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = 7 } - } + ] }, new CustomFormatSpecificationData { @@ -402,15 +402,15 @@ public class CustomFormatDataComparerTest Implementation = "SourceSpecification", Negate = true, Required = true, - Fields = new[] - { + Fields = + [ new CustomFormatFieldData { Value = 8 } - } + ] } - } + ] }; var result = CustomFormatData.Comparer.Equals(a, b); diff --git a/tests/Recyclarr.Cli.Tests/Pipelines/CustomFormat/Models/FieldsArrayJsonConverterTest.cs b/tests/Recyclarr.Cli.Tests/Pipelines/CustomFormat/Models/FieldsArrayJsonConverterTest.cs index cfa0238d..8e1ae8a3 100644 --- a/tests/Recyclarr.Cli.Tests/Pipelines/CustomFormat/Models/FieldsArrayJsonConverterTest.cs +++ b/tests/Recyclarr.Cli.Tests/Pipelines/CustomFormat/Models/FieldsArrayJsonConverterTest.cs @@ -41,11 +41,10 @@ public class FieldsArrayJsonConverterTest var result = JsonSerializer.Deserialize(json, GlobalJsonSerializerSettings.Services); - result!.Fields.Should().BeEquivalentTo(new[] - { + result!.Fields.Should().BeEquivalentTo([ new CustomFormatFieldData {Value = 25}, new CustomFormatFieldData {Value = 40} - }); + ]); } [Test] @@ -69,10 +68,9 @@ public class FieldsArrayJsonConverterTest var result = JsonSerializer.Deserialize(json, GlobalJsonSerializerSettings.Services); - result!.Fields.Should().BeEquivalentTo(new[] - { + result!.Fields.Should().BeEquivalentTo([ new CustomFormatFieldData {Value = "25"} - }); + ]); } [Test] diff --git a/tests/Recyclarr.Cli.Tests/Pipelines/CustomFormat/PipelinePhases/CustomFormatConfigPhaseTest.cs b/tests/Recyclarr.Cli.Tests/Pipelines/CustomFormat/PipelinePhases/CustomFormatConfigPhaseTest.cs index c32037b1..c5dcd2ef 100644 --- a/tests/Recyclarr.Cli.Tests/Pipelines/CustomFormat/PipelinePhases/CustomFormatConfigPhaseTest.cs +++ b/tests/Recyclarr.Cli.Tests/Pipelines/CustomFormat/PipelinePhases/CustomFormatConfigPhaseTest.cs @@ -16,11 +16,10 @@ public class CustomFormatConfigPhaseTest var fixture = NSubstituteFixture.Create(); var guide = fixture.Freeze(); - guide.GetCustomFormatData(default!).ReturnsForAnyArgs(new[] - { + guide.GetCustomFormatData(default!).ReturnsForAnyArgs([ NewCf.Data("one", "cf1"), NewCf.Data("two", "cf2") - }); + ]); fixture.Inject(NewConfig.Radarr() with { @@ -41,11 +40,10 @@ public class CustomFormatConfigPhaseTest var sut = fixture.Create(); sut.Execute(context); - context.ConfigOutput.Should().BeEquivalentTo(new[] - { + context.ConfigOutput.Should().BeEquivalentTo([ NewCf.Data("one", "cf1"), NewCf.Data("two", "cf2") - }); + ]); } [Test] @@ -54,10 +52,9 @@ public class CustomFormatConfigPhaseTest var fixture = NSubstituteFixture.Create(); var guide = fixture.Freeze(); - guide.GetCustomFormatData(default!).ReturnsForAnyArgs(new[] - { + guide.GetCustomFormatData(default!).ReturnsForAnyArgs([ NewCf.Data("", "cf4") - }); + ]); fixture.Inject(NewConfig.Radarr() with { diff --git a/tests/Recyclarr.Cli.Tests/Pipelines/MediaNaming/Config/SonarrMediaNamingConfigPhaseTest.cs b/tests/Recyclarr.Cli.Tests/Pipelines/MediaNaming/Config/SonarrMediaNamingConfigPhaseTest.cs index 46bc24df..e6a5c5c7 100644 --- a/tests/Recyclarr.Cli.Tests/Pipelines/MediaNaming/Config/SonarrMediaNamingConfigPhaseTest.cs +++ b/tests/Recyclarr.Cli.Tests/Pipelines/MediaNaming/Config/SonarrMediaNamingConfigPhaseTest.cs @@ -123,13 +123,12 @@ public class SonarrMediaNamingConfigPhaseTest RenameEpisodes = true }); - lookup.Errors.Should().BeEquivalentTo(new[] - { + lookup.Errors.Should().BeEquivalentTo([ new InvalidNamingConfig("Season Folder Format", "bad1"), new InvalidNamingConfig("Series Folder Format", "bad2"), new InvalidNamingConfig("Standard Episode Format", "bad3"), new InvalidNamingConfig("Daily Episode Format", "bad4"), new InvalidNamingConfig("Anime Episode Format", "bad5") - }); + ]); } } diff --git a/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/Api/QualityProfileDtoTest.cs b/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/Api/QualityProfileDtoTest.cs index 5d533181..55996a7b 100644 --- a/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/Api/QualityProfileDtoTest.cs +++ b/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/Api/QualityProfileDtoTest.cs @@ -66,11 +66,11 @@ public class QualityProfileDtoTest { var dto = new QualityProfileDto { - Items = new[] - { + Items = + [ NewQp.QualityDto(1, "one", true), NewQp.QualityDto(2, "two", true) - } + ] }; var result = dto with {Items = Array.Empty()}; diff --git a/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/PipelinePhases/QualityProfileConfigPhaseTest.cs b/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/PipelinePhases/QualityProfileConfigPhaseTest.cs index 81c0950c..e77c6918 100644 --- a/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/PipelinePhases/QualityProfileConfigPhaseTest.cs +++ b/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/PipelinePhases/QualityProfileConfigPhaseTest.cs @@ -24,15 +24,14 @@ public class QualityProfileConfigPhaseTest var fixture = NSubstituteFixture.Create(); var cache = fixture.Freeze(); - cache.AddCustomFormats(new[] - { + cache.AddCustomFormats([ NewCf.DataWithScore("", "id1", 101, 1), NewCf.DataWithScore("", "id2", 201, 2) - }); + ]); fixture.Inject(SetupCfs(new CustomFormatConfig { - TrashIds = new[] {"id1", "id2"}, + TrashIds = ["id1", "id2"], AssignScoresTo = new List { new() @@ -48,10 +47,9 @@ public class QualityProfileConfigPhaseTest sut.Execute(context); - context.ConfigOutput.Should().BeEquivalentTo(new[] - { + context.ConfigOutput.Should().BeEquivalentTo([ NewQp.Processed("test_profile", ("id1", 1, 100), ("id2", 2, 100)) - }, + ], o => o.Excluding(x => x.ShouldCreate)); } @@ -61,15 +59,14 @@ public class QualityProfileConfigPhaseTest var fixture = NSubstituteFixture.Create(); var cache = fixture.Freeze(); - cache.AddCustomFormats(new[] - { + cache.AddCustomFormats([ NewCf.DataWithScore("", "id1", 100, 1), NewCf.DataWithScore("", "id2", 200, 2) - }); + ]); fixture.Inject(SetupCfs(new CustomFormatConfig { - TrashIds = new[] {"id1", "id2"}, + TrashIds = ["id1", "id2"], AssignScoresTo = new List { new() @@ -83,10 +80,9 @@ public class QualityProfileConfigPhaseTest var sut = fixture.Create(); sut.Execute(context); - context.ConfigOutput.Should().BeEquivalentTo(new[] - { + context.ConfigOutput.Should().BeEquivalentTo([ NewQp.Processed("test_profile", ("id1", 1, 100), ("id2", 2, 200)) - }, + ], o => o.Excluding(x => x.ShouldCreate)); } @@ -96,15 +92,14 @@ public class QualityProfileConfigPhaseTest var fixture = NSubstituteFixture.Create(); var cache = fixture.Freeze(); - cache.AddCustomFormats(new[] - { + cache.AddCustomFormats([ NewCf.Data("", "id1", 1), NewCf.Data("", "id2", 2) - }); + ]); fixture.Inject(SetupCfs(new CustomFormatConfig { - TrashIds = new[] {"id1", "id2"}, + TrashIds = ["id1", "id2"], AssignScoresTo = new List { new() @@ -118,10 +113,9 @@ public class QualityProfileConfigPhaseTest var sut = fixture.Create(); sut.Execute(context); - context.ConfigOutput.Should().BeEquivalentTo(new[] - { + context.ConfigOutput.Should().BeEquivalentTo([ NewQp.Processed("test_profile") - }, + ], o => o.Excluding(x => x.ShouldCreate).Excluding(x => x.ScorelessCfs)); } @@ -131,19 +125,18 @@ public class QualityProfileConfigPhaseTest var fixture = NSubstituteFixture.Create(); var cache = fixture.Freeze(); - cache.AddCustomFormats(new[] - { + cache.AddCustomFormats([ NewCf.DataWithScore("", "id1", 100, 1) - }); + ]); fixture.Inject(SetupCfs( new CustomFormatConfig { - TrashIds = new[] {"id1"} + TrashIds = ["id1"] }, new CustomFormatConfig { - TrashIds = new[] {"id1"}, + TrashIds = ["id1"], AssignScoresTo = new List { new() {Name = "test_profile1", Score = 100} @@ -151,7 +144,7 @@ public class QualityProfileConfigPhaseTest }, new CustomFormatConfig { - TrashIds = new[] {"id1"}, + TrashIds = ["id1"], AssignScoresTo = new List { new() {Name = "test_profile1", Score = 200} @@ -159,7 +152,7 @@ public class QualityProfileConfigPhaseTest }, new CustomFormatConfig { - TrashIds = new[] {"id1"}, + TrashIds = ["id1"], AssignScoresTo = new List { new() {Name = "test_profile2", Score = 200} @@ -167,7 +160,7 @@ public class QualityProfileConfigPhaseTest }, new CustomFormatConfig { - TrashIds = new[] {"id1"}, + TrashIds = ["id1"], AssignScoresTo = new List { new() {Name = "test_profile2", Score = 100} @@ -179,11 +172,10 @@ public class QualityProfileConfigPhaseTest var sut = fixture.Create(); sut.Execute(context); - context.ConfigOutput.Should().BeEquivalentTo(new[] - { + context.ConfigOutput.Should().BeEquivalentTo([ NewQp.Processed("test_profile1", ("id1", 1, 100)), NewQp.Processed("test_profile2", ("id1", 1, 200)) - }, + ], o => o.Excluding(x => x.ShouldCreate)); } @@ -193,33 +185,32 @@ public class QualityProfileConfigPhaseTest var fixture = NSubstituteFixture.Create(); var cache = fixture.Freeze(); - cache.AddCustomFormats(new[] - { + cache.AddCustomFormats([ NewCf.DataWithScores("", "id1", 1, ("default", 101), ("set1", 102)), NewCf.DataWithScores("", "id2", 2, ("default", 201), ("set2", 202)) - }); + ]); var config = NewConfig.Radarr() with { - CustomFormats = new[] - { + CustomFormats = + [ new CustomFormatConfig { - TrashIds = new[] {"id1", "id2"}, - AssignScoresTo = new[] - { + TrashIds = ["id1", "id2"], + AssignScoresTo = + [ new AssignScoresToConfig {Name = "test_profile"} - } + ] } - }, - QualityProfiles = new[] - { + ], + QualityProfiles = + [ new QualityProfileConfig { Name = "test_profile", ScoreSet = "set1" } - } + ] }; fixture.Inject(config); @@ -227,13 +218,12 @@ public class QualityProfileConfigPhaseTest var sut = fixture.Create(); sut.Execute(context); - context.ConfigOutput.Should().BeEquivalentTo(new[] - { + context.ConfigOutput.Should().BeEquivalentTo([ NewQp.Processed("test_profile", ("id1", 1, 102), ("id2", 2, 201)) with { Profile = config.QualityProfiles.First() } - }, + ], o => o.Excluding(x => x.ShouldCreate)); } @@ -268,15 +258,14 @@ public class QualityProfileConfigPhaseTest var fixture = NSubstituteFixture.Create(); var cache = fixture.Freeze(); - cache.AddCustomFormats(new[] - { + cache.AddCustomFormats([ NewCf.DataWithScore("", "id1", 101, 1), NewCf.DataWithScore("", "id2", 201, 2) - }); + ]); fixture.Inject(SetupCfs(new CustomFormatConfig { - TrashIds = new[] {"id1", "id2"}, + TrashIds = ["id1", "id2"], AssignScoresTo = Array.Empty() })); diff --git a/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/PipelinePhases/QualityProfileTransactionPhaseTest.cs b/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/PipelinePhases/QualityProfileTransactionPhaseTest.cs index 703bdef5..0572c7cc 100644 --- a/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/PipelinePhases/QualityProfileTransactionPhaseTest.cs +++ b/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/PipelinePhases/QualityProfileTransactionPhaseTest.cs @@ -20,14 +20,14 @@ public class QualityProfileTransactionPhaseTest var context = new QualityProfilePipelineContext { - ConfigOutput = new[] - { + ConfigOutput = + [ NewQp.Processed("invalid_profile_name") with { ShouldCreate = false }, NewQp.Processed("profile1") - }, + ], ApiFetchOutput = new QualityProfileServiceData(dtos, new QualityProfileDto()) }; @@ -35,7 +35,7 @@ public class QualityProfileTransactionPhaseTest context.TransactionOutput.Should().BeEquivalentTo(new QualityProfileTransactionData { - NonExistentProfiles = new[] {"invalid_profile_name"}, + NonExistentProfiles = ["invalid_profile_name"], UnchangedProfiles = new List { new() @@ -62,28 +62,28 @@ public class QualityProfileTransactionPhaseTest var context = new QualityProfilePipelineContext { - ConfigOutput = new[] - { + ConfigOutput = + [ new ProcessedQualityProfileData { Profile = new QualityProfileConfig { Name = "profile1", - Qualities = new[] - { + Qualities = + [ new QualityProfileQualityConfig {Name = "quality1", Enabled = true} - } + ] } } - }, + ], ApiFetchOutput = new QualityProfileServiceData(dtos, new QualityProfileDto()) { Schema = new QualityProfileDto { - Items = new[] - { + Items = + [ new ProfileItemDto {Quality = new ProfileItemQualityDto {Name = "quality1"}} - } + ] } } }; @@ -105,8 +105,8 @@ public class QualityProfileTransactionPhaseTest UpdatedQualities = new UpdatedQualities { NumWantedItems = 1, - Items = new[] - { + Items = + [ new ProfileItemDto { Allowed = true, @@ -115,7 +115,7 @@ public class QualityProfileTransactionPhaseTest Name = "quality1" } } - } + ] } } } @@ -132,8 +132,8 @@ public class QualityProfileTransactionPhaseTest new QualityProfileDto { Name = "profile1", - FormatItems = new[] - { + FormatItems = + [ new ProfileFormatItemDto { Name = "quality1", @@ -146,16 +146,16 @@ public class QualityProfileTransactionPhaseTest Format = 2, Score = 300 } - } + ] } }; var context = new QualityProfilePipelineContext { - ConfigOutput = new[] - { + ConfigOutput = + [ NewQp.Processed("profile1", ("id1", 1, 100), ("id2", 2, 500)) - }, + ], ApiFetchOutput = new QualityProfileServiceData(dtos, new QualityProfileDto()) }; @@ -163,11 +163,10 @@ public class QualityProfileTransactionPhaseTest context.TransactionOutput.ChangedProfiles.Should() .ContainSingle().Which.Profile.UpdatedScores.Should() - .BeEquivalentTo(new[] - { + .BeEquivalentTo([ NewQp.UpdatedScore("quality1", 200, 100, FormatScoreUpdateReason.Updated), NewQp.UpdatedScore("quality2", 300, 500, FormatScoreUpdateReason.Updated) - }, o => o.Excluding(x => x.Dto.Format)); + ], o => o.Excluding(x => x.Dto.Format)); } [Test, AutoMockData] @@ -179,8 +178,8 @@ public class QualityProfileTransactionPhaseTest new QualityProfileDto { Name = "profile1", - FormatItems = new[] - { + FormatItems = + [ new ProfileFormatItemDto { Name = "quality1", @@ -193,7 +192,7 @@ public class QualityProfileTransactionPhaseTest Format = 2, Score = 300 } - } + ] } }; @@ -217,8 +216,8 @@ public class QualityProfileTransactionPhaseTest new QualityProfileDto { Name = "profile1", - FormatItems = new[] - { + FormatItems = + [ new ProfileFormatItemDto { Name = "quality1", @@ -231,7 +230,7 @@ public class QualityProfileTransactionPhaseTest Format = 2, Score = 300 } - } + ] } }; @@ -239,10 +238,10 @@ public class QualityProfileTransactionPhaseTest { // Must simulate at least 1 custom format coming from configuration otherwise processing doesn't happen. // Profile name must match but the format IDs for each quality should not - ConfigOutput = new[] - { + ConfigOutput = + [ NewQp.Processed("profile1", ("id1", 1, 200), ("id2", 2, 300)) - }, + ], ApiFetchOutput = new QualityProfileServiceData(dtos, new QualityProfileDto()) }; @@ -250,11 +249,10 @@ public class QualityProfileTransactionPhaseTest context.TransactionOutput.UnchangedProfiles.Should() .ContainSingle().Which.Profile.UpdatedScores.Should() - .BeEquivalentTo(new[] - { + .BeEquivalentTo([ NewQp.UpdatedScore("quality1", 200, 200, FormatScoreUpdateReason.NoChange), NewQp.UpdatedScore("quality2", 300, 300, FormatScoreUpdateReason.NoChange) - }, o => o.Excluding(x => x.Dto.Format)); + ], o => o.Excluding(x => x.Dto.Format)); } [Test, AutoMockData] @@ -266,8 +264,8 @@ public class QualityProfileTransactionPhaseTest new QualityProfileDto { Name = "profile1", - FormatItems = new[] - { + FormatItems = + [ new ProfileFormatItemDto { Name = "quality1", @@ -280,16 +278,16 @@ public class QualityProfileTransactionPhaseTest Format = 2, Score = 300 } - } + ] } }; var context = new QualityProfilePipelineContext { - ConfigOutput = new[] - { + ConfigOutput = + [ NewQp.Processed("profile1", true, ("quality3", "id3", 3, 100), ("quality4", "id4", 4, 500)) - }, + ], ApiFetchOutput = new QualityProfileServiceData(dtos, new QualityProfileDto()) }; @@ -297,13 +295,12 @@ public class QualityProfileTransactionPhaseTest context.TransactionOutput.ChangedProfiles.Should() .ContainSingle().Which.Profile.UpdatedScores.Should() - .BeEquivalentTo(new[] - { + .BeEquivalentTo([ NewQp.UpdatedScore("quality1", 200, 0, FormatScoreUpdateReason.Reset), NewQp.UpdatedScore("quality2", 300, 0, FormatScoreUpdateReason.Reset), NewQp.UpdatedScore("quality3", 0, 100, FormatScoreUpdateReason.New), NewQp.UpdatedScore("quality4", 0, 500, FormatScoreUpdateReason.New) - }, o => o.Excluding(x => x.Dto.Format)); + ], o => o.Excluding(x => x.Dto.Format)); } [Test, AutoMockData] @@ -314,8 +311,8 @@ public class QualityProfileTransactionPhaseTest new QualityProfileDto { Name = "profile1", - FormatItems = new[] - { + FormatItems = + [ new ProfileFormatItemDto { Name = "cf1", @@ -328,14 +325,14 @@ public class QualityProfileTransactionPhaseTest Format = 2, Score = 300 } - } + ] } }; var context = new QualityProfilePipelineContext { - ConfigOutput = new[] - { + ConfigOutput = + [ NewQp.Processed(new QualityProfileConfig { Name = "profile1", @@ -344,11 +341,11 @@ public class QualityProfileTransactionPhaseTest Enabled = false, // Throw in some exceptions here, just to test whether or not these somehow affect the // result despite Enable being set to false. - Except = new[] {"cf1"} + Except = ["cf1"] } }, ("cf3", "id3", 3, 100), ("cf4", "id4", 4, 500)) - }, + ], ApiFetchOutput = new QualityProfileServiceData(dtos, new QualityProfileDto()) }; @@ -356,13 +353,12 @@ public class QualityProfileTransactionPhaseTest context.TransactionOutput.ChangedProfiles.Should() .ContainSingle().Which.Profile.UpdatedScores.Should() - .BeEquivalentTo(new[] - { + .BeEquivalentTo([ NewQp.UpdatedScore("cf1", 200, 200, FormatScoreUpdateReason.NoChange), NewQp.UpdatedScore("cf2", 300, 300, FormatScoreUpdateReason.NoChange), NewQp.UpdatedScore("cf3", 0, 100, FormatScoreUpdateReason.New), NewQp.UpdatedScore("cf4", 0, 500, FormatScoreUpdateReason.New) - }, o => o.Excluding(x => x.Dto.Format)); + ], o => o.Excluding(x => x.Dto.Format)); } [Test, AutoMockData] @@ -373,8 +369,8 @@ public class QualityProfileTransactionPhaseTest new QualityProfileDto { Name = "profile1", - FormatItems = new[] - { + FormatItems = + [ new ProfileFormatItemDto { Name = "cf1", @@ -387,25 +383,25 @@ public class QualityProfileTransactionPhaseTest Format = 2, Score = 300 } - } + ] } }; var context = new QualityProfilePipelineContext { - ConfigOutput = new[] - { + ConfigOutput = + [ NewQp.Processed(new QualityProfileConfig { Name = "profile1", ResetUnmatchedScores = new ResetUnmatchedScoresConfig { Enabled = true, - Except = new[] {"cf1"} + Except = ["cf1"] } }, ("cf3", "id3", 3, 100), ("cf4", "id4", 4, 500)) - }, + ], ApiFetchOutput = new QualityProfileServiceData(dtos, new QualityProfileDto()) }; @@ -413,13 +409,12 @@ public class QualityProfileTransactionPhaseTest context.TransactionOutput.ChangedProfiles.Should() .ContainSingle().Which.Profile.UpdatedScores.Should() - .BeEquivalentTo(new[] - { + .BeEquivalentTo([ NewQp.UpdatedScore("cf1", 200, 200, FormatScoreUpdateReason.NoChange), NewQp.UpdatedScore("cf2", 300, 0, FormatScoreUpdateReason.Reset), NewQp.UpdatedScore("cf3", 0, 100, FormatScoreUpdateReason.New), NewQp.UpdatedScore("cf4", 0, 500, FormatScoreUpdateReason.New) - }, o => o.Excluding(x => x.Dto.Format)); + ], o => o.Excluding(x => x.Dto.Format)); } [Test, AutoMockData] @@ -430,8 +425,8 @@ public class QualityProfileTransactionPhaseTest new QualityProfileDto { Name = "profile1", - FormatItems = new[] - { + FormatItems = + [ new ProfileFormatItemDto { Name = "cf1", @@ -444,24 +439,24 @@ public class QualityProfileTransactionPhaseTest Format = 2, Score = 300 } - } + ] } }; var context = new QualityProfilePipelineContext { - ConfigOutput = new[] - { + ConfigOutput = + [ NewQp.Processed(new QualityProfileConfig { Name = "profile1", ResetUnmatchedScores = new ResetUnmatchedScoresConfig { Enabled = true, - Except = new[] {"cf50"} + Except = ["cf50"] } }) - }, + ], ApiFetchOutput = new QualityProfileServiceData(dtos, new QualityProfileDto()) }; @@ -480,8 +475,8 @@ public class QualityProfileTransactionPhaseTest new QualityProfileDto { Name = "profile1", - Items = new[] - { + Items = + [ new ProfileItemDto { Quality = new ProfileItemQualityDto {Id = 1, Name = "One"} @@ -490,14 +485,14 @@ public class QualityProfileTransactionPhaseTest { Quality = new ProfileItemQualityDto {Id = 2, Name = "Two"} } - } + ] } }; var context = new QualityProfilePipelineContext { - ConfigOutput = new[] - { + ConfigOutput = + [ new ProcessedQualityProfileData { Profile = new QualityProfileConfig @@ -505,17 +500,17 @@ public class QualityProfileTransactionPhaseTest Name = "profile1" } } - }, + ], ApiFetchOutput = new QualityProfileServiceData(dtos, new QualityProfileDto()) { Schema = new QualityProfileDto { - Items = new[] - { + Items = + [ new ProfileItemDto {Quality = new ProfileItemQualityDto {Id = 1, Name = "One"}}, new ProfileItemDto {Quality = new ProfileItemQualityDto {Id = 2, Name = "Two"}}, new ProfileItemDto {Quality = new ProfileItemQualityDto {Id = 3, Name = "Three"}} - } + ] } } }; diff --git a/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/QualityItemOrganizerTest.cs b/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/QualityItemOrganizerTest.cs index 9cf9f7bd..191b1954 100644 --- a/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/QualityItemOrganizerTest.cs +++ b/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/QualityItemOrganizerTest.cs @@ -9,8 +9,8 @@ public class QualityItemOrganizerTest { private readonly QualityProfileConfig _config = new() { - Qualities = new[] - { + Qualities = + [ NewQp.QualityConfig("one"), NewQp.QualityConfig("three"), NewQp.QualityConfig("six", false), @@ -19,13 +19,13 @@ public class QualityItemOrganizerTest NewQp.GroupConfig("group3", "eight"), NewQp.GroupConfig("group4", false, "nine", "ten"), NewQp.GroupConfig("group5", "eleven") - } + ] }; private readonly QualityProfileDto _dto = new() { - Items = new[] - { + Items = + [ NewQp.QualityDto(1, "one", true), NewQp.QualityDto(2, "two", true), NewQp.QualityDto(3, "three", true), @@ -40,7 +40,7 @@ public class QualityItemOrganizerTest NewQp.GroupDto(1002, "group2", true, NewQp.QualityDto(7, "seven", true)), NewQp.QualityDto(8, "eight", true) - } + ] }; [Test] @@ -54,10 +54,10 @@ public class QualityItemOrganizerTest result.Should().BeEquivalentTo(new UpdatedQualities { - InvalidQualityNames = new[] {"nonexistent1"}, + InvalidQualityNames = ["nonexistent1"], NumWantedItems = 7, - Items = new[] - { + Items = + [ // ------ IN CONFIG ------ NewQp.QualityDto(1, "one", true), NewQp.QualityDto(3, "three", true), @@ -74,7 +74,7 @@ public class QualityItemOrganizerTest NewQp.QualityDto(2, "two", false), NewQp.QualityDto(4, "four", false), NewQp.QualityDto(5, "five", false) - } + ] }); } @@ -89,10 +89,10 @@ public class QualityItemOrganizerTest result.Should().BeEquivalentTo(new UpdatedQualities { - InvalidQualityNames = new[] {"nonexistent1"}, + InvalidQualityNames = ["nonexistent1"], NumWantedItems = 7, - Items = new[] - { + Items = + [ // ------ NOT IN CONFIG ------ NewQp.QualityDto(2, "two", false), NewQp.QualityDto(4, "four", false), @@ -109,7 +109,7 @@ public class QualityItemOrganizerTest NewQp.QualityDto(10, "ten", false)), NewQp.GroupDto(50, "group5", true, NewQp.QualityDto(11, "eleven", true)) - } + ] }); } @@ -118,28 +118,27 @@ public class QualityItemOrganizerTest { var config = new QualityProfileConfig { - Qualities = new[] - { + Qualities = + [ NewQp.QualityConfig("one") - } + ] }; var dto = new QualityProfileDto { - Items = new[] - { + Items = + [ NewQp.GroupDto(1001, "group1", true, NewQp.QualityDto(1, "one", true)) - } + ] }; var sut = new QualityItemOrganizer(); var result = sut.OrganizeItems(dto, config); - result.Items.Should().BeEquivalentTo(new[] - { + result.Items.Should().BeEquivalentTo([ NewQp.QualityDto(1, "one", true) - }); + ]); } [Test] @@ -147,30 +146,29 @@ public class QualityItemOrganizerTest { var config = new QualityProfileConfig { - Qualities = new[] - { + Qualities = + [ NewQp.QualityConfig("one") - } + ] }; var dto = new QualityProfileDto { - Items = new[] - { + Items = + [ NewQp.GroupDto(1001, "group1", true, NewQp.QualityDto(1, "one", true), NewQp.QualityDto(2, "two", true)) - } + ] }; var sut = new QualityItemOrganizer(); var result = sut.OrganizeItems(dto, config); - result.Items.Should().BeEquivalentTo(new[] - { + result.Items.Should().BeEquivalentTo([ NewQp.QualityDto(1, "one", true), NewQp.QualityDto(2, "two", false) - }); + ]); } [Test] @@ -178,33 +176,32 @@ public class QualityItemOrganizerTest { var config = new QualityProfileConfig { - Qualities = new[] - { + Qualities = + [ NewQp.QualityConfig("one") - } + ] }; var dto = new QualityProfileDto { - Items = new[] - { + Items = + [ NewQp.GroupDto(1001, "group1", true, NewQp.QualityDto(1, "one", true), NewQp.QualityDto(2, "two", true), NewQp.QualityDto(3, "three", true)) - } + ] }; var sut = new QualityItemOrganizer(); var result = sut.OrganizeItems(dto, config); - result.Items.Should().BeEquivalentTo(new[] - { + result.Items.Should().BeEquivalentTo([ NewQp.QualityDto(1, "one", true), NewQp.GroupDto(1001, "group1", false, NewQp.QualityDto(2, "two", false), NewQp.QualityDto(3, "three", false)) - }); + ]); } [Test] @@ -212,34 +209,33 @@ public class QualityItemOrganizerTest { var config = new QualityProfileConfig { - Qualities = new[] - { + Qualities = + [ NewQp.GroupConfig("group1", "one", "two", "three") - } + ] }; var dto = new QualityProfileDto { - Items = new[] - { + Items = + [ NewQp.GroupDto(1001, "group1", true, NewQp.QualityDto(1, "one", true), NewQp.QualityDto(2, "two", true), NewQp.QualityDto(3, "three", true), NewQp.QualityDto(4, "four", true)) - } + ] }; var sut = new QualityItemOrganizer(); var result = sut.OrganizeItems(dto, config); - result.Items.Should().BeEquivalentTo(new[] - { + result.Items.Should().BeEquivalentTo([ NewQp.GroupDto(1001, "group1", true, NewQp.QualityDto(1, "one", true), NewQp.QualityDto(2, "two", true), NewQp.QualityDto(3, "three", true)), NewQp.QualityDto(4, "four", false) - }); + ]); } } diff --git a/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/QualityProfileExtensionsTest.cs b/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/QualityProfileExtensionsTest.cs index 1a25864d..4768b7bd 100644 --- a/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/QualityProfileExtensionsTest.cs +++ b/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/QualityProfileExtensionsTest.cs @@ -386,8 +386,7 @@ public class QualityProfileExtensionsTest var result = dto.ReverseItems(); - result.Items.Should().BeEquivalentTo(new[] - { + result.Items.Should().BeEquivalentTo([ NewQp.GroupDto(1003, "Group 3", true, NewQp.QualityDto(4, "Quality 4", true)), NewQp.GroupDto(1002, "Group 2", true, @@ -395,7 +394,7 @@ public class QualityProfileExtensionsTest NewQp.QualityDto(2, "Quality 2", true)), NewQp.QualityDto(1, "Quality 1", true), NewQp.GroupDto(1001, "Group 1", true) - }); + ]); } [Test] diff --git a/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/UpdatedQualityProfileTest.cs b/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/UpdatedQualityProfileTest.cs index bdfa61a6..e472a7fa 100644 --- a/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/UpdatedQualityProfileTest.cs +++ b/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/UpdatedQualityProfileTest.cs @@ -127,10 +127,10 @@ public class UpdatedQualityProfileTest ProfileConfig = NewQp.Processed("config_name"), UpdatedQualities = new UpdatedQualities { - Items = new[] - { + Items = + [ new ProfileItemDto() - } + ] }, UpdateReason = QualityProfileUpdateReason.New }; diff --git a/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/UpdatedQualityProfileValidatorTest.cs b/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/UpdatedQualityProfileValidatorTest.cs index f990297d..2730a3a2 100644 --- a/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/UpdatedQualityProfileValidatorTest.cs +++ b/tests/Recyclarr.Cli.Tests/Pipelines/QualityProfile/UpdatedQualityProfileValidatorTest.cs @@ -18,13 +18,13 @@ public class UpdatedQualityProfileValidatorTest var updatedProfile = new UpdatedQualityProfile { - UpdatedScores = new[] - { + UpdatedScores = + [ NewQp.UpdatedScore("foo1", 0, 100, FormatScoreUpdateReason.New), NewQp.UpdatedScore("foo2", 0, -100, FormatScoreUpdateReason.Updated), NewQp.UpdatedScore("foo3", 0, 200, FormatScoreUpdateReason.NoChange), NewQp.UpdatedScore("foo4", 0, 100, FormatScoreUpdateReason.Reset) - }, + ], ProfileDto = new QualityProfileDto {Name = "ProfileName"}, ProfileConfig = NewQp.Processed(profileConfig), UpdateReason = QualityProfileUpdateReason.Changed @@ -60,7 +60,7 @@ public class UpdatedQualityProfileValidatorTest { UpdatedQualities = new UpdatedQualities { - InvalidQualityNames = new[] {"foo1"} + InvalidQualityNames = ["foo1"] }, ProfileDto = new QualityProfileDto(), ProfileConfig = NewQp.Processed(profileConfig), @@ -105,10 +105,10 @@ public class UpdatedQualityProfileValidatorTest { ProfileDto = new QualityProfileDto { - Items = new[] - { + Items = + [ NewQp.QualityDto(1, "disabled_quality", false) - } + ] }, ProfileConfig = NewQp.Processed(profileConfig), UpdateReason = QualityProfileUpdateReason.New diff --git a/tests/Recyclarr.Cli.Tests/Pipelines/QualitySize/PipelinePhases/QualitySizeConfigPhaseTest.cs b/tests/Recyclarr.Cli.Tests/Pipelines/QualitySize/PipelinePhases/QualitySizeConfigPhaseTest.cs index 2f564f20..9c58f650 100644 --- a/tests/Recyclarr.Cli.Tests/Pipelines/QualitySize/PipelinePhases/QualitySizeConfigPhaseTest.cs +++ b/tests/Recyclarr.Cli.Tests/Pipelines/QualitySize/PipelinePhases/QualitySizeConfigPhaseTest.cs @@ -31,10 +31,9 @@ public class QualitySizeConfigPhaseTest { config.QualityDefinition.Returns(new QualityDefinitionConfig {Type = "not_real"}); - guide.GetQualitySizeData(default!).ReturnsForAnyArgs(new[] - { + guide.GetQualitySizeData(default!).ReturnsForAnyArgs([ new QualitySizeData {Type = "real"} - }); + ]); var context = new QualitySizePipelineContext(); @@ -59,10 +58,9 @@ public class QualitySizeConfigPhaseTest PreferredRatio = decimal.Parse(testPreferred) }); - guide.GetQualitySizeData(default!).ReturnsForAnyArgs(new[] - { + guide.GetQualitySizeData(default!).ReturnsForAnyArgs([ new QualitySizeData {Type = "real"} - }); + ]); var context = new QualitySizePipelineContext(); @@ -85,27 +83,25 @@ public class QualitySizeConfigPhaseTest PreferredRatio = 0.5m }); - guide.GetQualitySizeData(default!).ReturnsForAnyArgs(new[] - { + guide.GetQualitySizeData(default!).ReturnsForAnyArgs([ new QualitySizeData { Type = "real", - Qualities = new[] - { + Qualities = + [ new QualityItem("quality1", 0, 100, 90) - } + ] } - }); + ]); var context = new QualitySizePipelineContext(); sut.Execute(context); context.ConfigOutput.Should().NotBeNull(); - context.ConfigOutput!.Qualities.Select(x => x.Item).Should().BeEquivalentTo(new[] - { + context.ConfigOutput!.Qualities.Select(x => x.Item).Should().BeEquivalentTo([ new QualityItem("quality1", 0, 100, 50) - }); + ]); } [Test, AutoMockData] @@ -119,26 +115,24 @@ public class QualitySizeConfigPhaseTest Type = "real" }); - guide.GetQualitySizeData(default!).ReturnsForAnyArgs(new[] - { + guide.GetQualitySizeData(default!).ReturnsForAnyArgs([ new QualitySizeData { Type = "real", - Qualities = new[] - { + Qualities = + [ new QualityItem("quality1", 0, 100, 90) - } + ] } - }); + ]); var context = new QualitySizePipelineContext(); sut.Execute(context); context.ConfigOutput.Should().NotBeNull(); - context.ConfigOutput!.Qualities.Select(x => x.Item).Should().BeEquivalentTo(new[] - { + context.ConfigOutput!.Qualities.Select(x => x.Item).Should().BeEquivalentTo([ new QualityItem("quality1", 0, 100, 90) - }); + ]); } } diff --git a/tests/Recyclarr.Cli.Tests/Processors/Config/TemplateConfigCreatorTest.cs b/tests/Recyclarr.Cli.Tests/Processors/Config/TemplateConfigCreatorTest.cs index 87559ca5..8f9fcfc6 100644 --- a/tests/Recyclarr.Cli.Tests/Processors/Config/TemplateConfigCreatorTest.cs +++ b/tests/Recyclarr.Cli.Tests/Processors/Config/TemplateConfigCreatorTest.cs @@ -14,7 +14,7 @@ public class TemplateConfigCreatorTest ICreateConfigSettings settings, TemplateConfigCreator sut) { - settings.Templates.Returns(new[] {"template1"}); + settings.Templates.Returns(["template1"]); var result = sut.CanHandle(settings); result.Should().Be(true); } diff --git a/tests/Recyclarr.Cli.Tests/Processors/ConfigTemplateListerTest.cs b/tests/Recyclarr.Cli.Tests/Processors/ConfigTemplateListerTest.cs index e55bf888..c955c30c 100644 --- a/tests/Recyclarr.Cli.Tests/Processors/ConfigTemplateListerTest.cs +++ b/tests/Recyclarr.Cli.Tests/Processors/ConfigTemplateListerTest.cs @@ -16,13 +16,12 @@ public class ConfigTemplateListerTest [Frozen] IConfigTemplateGuideService guideService, ConfigListTemplateProcessor sut) { - guideService.GetTemplateData().Returns(new[] - { + guideService.GetTemplateData().Returns([ new TemplatePath {Id = "r1", TemplateFile = stubFile, Service = SupportedServices.Radarr, Hidden = false}, new TemplatePath {Id = "r2", TemplateFile = stubFile, Service = SupportedServices.Radarr, Hidden = false}, new TemplatePath {Id = "s1", TemplateFile = stubFile, Service = SupportedServices.Sonarr, Hidden = false}, new TemplatePath {Id = "s2", TemplateFile = stubFile, Service = SupportedServices.Sonarr, Hidden = true} - }); + ]); var settings = Substitute.For(); settings.Includes.Returns(false); diff --git a/tests/Recyclarr.IntegrationTests/BulkJsonLoaderIntegrationTest.cs b/tests/Recyclarr.IntegrationTests/BulkJsonLoaderIntegrationTest.cs index d3fbd222..a668af8e 100644 --- a/tests/Recyclarr.IntegrationTests/BulkJsonLoaderIntegrationTest.cs +++ b/tests/Recyclarr.IntegrationTests/BulkJsonLoaderIntegrationTest.cs @@ -29,12 +29,11 @@ public class BulkJsonLoaderIntegrationTest : IntegrationTestFixture Fs.AddFile(Fs.CurrentDirectory().File("file.json"), new MockFileData(jsonData)); - var result = sut.LoadAllFilesAtPaths(new[] {Fs.CurrentDirectory()}); + var result = sut.LoadAllFilesAtPaths([Fs.CurrentDirectory()]); - result.Should().BeEquivalentTo(new[] - { + result.Should().BeEquivalentTo([ new TestGuideObject("90cedc1fea7ea5d11298bebd3d1d3223", -10000, "TheName") - }); + ]); } [Test] @@ -53,11 +52,10 @@ public class BulkJsonLoaderIntegrationTest : IntegrationTestFixture Fs.AddFile(Fs.CurrentDirectory().File("file.json"), new MockFileData(jsonData)); - var result = sut.LoadAllFilesAtPaths(new[] {Fs.CurrentDirectory()}); + var result = sut.LoadAllFilesAtPaths([Fs.CurrentDirectory()]); - result.Should().BeEquivalentTo(new[] - { + result.Should().BeEquivalentTo([ new TestServiceObject(22, "FUNi", true) - }); + ]); } } diff --git a/tests/Recyclarr.IntegrationTests/ConfigurationLoaderEnvVarTest.cs b/tests/Recyclarr.IntegrationTests/ConfigurationLoaderEnvVarTest.cs index 89b2d9a9..fa2e65c7 100644 --- a/tests/Recyclarr.IntegrationTests/ConfigurationLoaderEnvVarTest.cs +++ b/tests/Recyclarr.IntegrationTests/ConfigurationLoaderEnvVarTest.cs @@ -25,14 +25,13 @@ public class ConfigurationLoaderEnvVarTest : IntegrationTestFixture var config = sut.Load(testYml); - config.Should().BeEquivalentTo(new[] - { + config.Should().BeEquivalentTo([ new { BaseUrl = new Uri("http://the_url"), ApiKey = "the_api_key" } - }); + ]); } [Test] @@ -49,13 +48,12 @@ public class ConfigurationLoaderEnvVarTest : IntegrationTestFixture """; var config = sut.Load(testYml); - config.Should().BeEquivalentTo(new[] - { + config.Should().BeEquivalentTo([ new { BaseUrl = new Uri("http://sonarr:1233") } - }); + ]); } [Test] @@ -75,13 +73,12 @@ public class ConfigurationLoaderEnvVarTest : IntegrationTestFixture """; var config = sut.Load(testYml); - config.Should().BeEquivalentTo(new[] - { + config.Should().BeEquivalentTo([ new { BaseUrl = new Uri("http://somevalue") } - }); + ]); } [Test] @@ -101,14 +98,13 @@ public class ConfigurationLoaderEnvVarTest : IntegrationTestFixture """; var config = sut.Load(testYml); - config.Should().BeEquivalentTo(new[] - { + config.Should().BeEquivalentTo([ new { BaseUrl = new Uri("http://theurl"), ApiKey = "the key" } - }); + ]); } [Test] @@ -125,13 +121,12 @@ public class ConfigurationLoaderEnvVarTest : IntegrationTestFixture """; var config = sut.Load(testYml); - config.Should().BeEquivalentTo(new[] - { + config.Should().BeEquivalentTo([ new { BaseUrl = new Uri("http://somevalue") } - }); + ]); } [Test] @@ -148,13 +143,12 @@ public class ConfigurationLoaderEnvVarTest : IntegrationTestFixture """; var config = sut.Load(testYml); - config.Should().BeEquivalentTo(new[] - { + config.Should().BeEquivalentTo([ new { BaseUrl = new Uri("http://somevalue") } - }); + ]); } [Test] diff --git a/tests/Recyclarr.IntegrationTests/ConfigurationRegistryTest.cs b/tests/Recyclarr.IntegrationTests/ConfigurationRegistryTest.cs index 6cb528e3..cbd3018f 100644 --- a/tests/Recyclarr.IntegrationTests/ConfigurationRegistryTest.cs +++ b/tests/Recyclarr.IntegrationTests/ConfigurationRegistryTest.cs @@ -23,18 +23,17 @@ public class ConfigurationRegistryTest : IntegrationTestFixture var result = sut.FindAndLoadConfigs(new ConfigFilterCriteria { - ManualConfigFiles = new[] {"manual.yml"} + ManualConfigFiles = ["manual.yml"] }); - result.Should().BeEquivalentTo(new[] - { + result.Should().BeEquivalentTo([ new RadarrConfiguration { BaseUrl = new Uri("http://localhost:7878"), ApiKey = "asdf", InstanceName = "instance1" } - }); + ]); } [Test] @@ -44,7 +43,7 @@ public class ConfigurationRegistryTest : IntegrationTestFixture var act = () => sut.FindAndLoadConfigs(new ConfigFilterCriteria { - ManualConfigFiles = new[] {"manual.yml"} + ManualConfigFiles = ["manual.yml"] }); act.Should().ThrowExactly(); @@ -65,8 +64,8 @@ public class ConfigurationRegistryTest : IntegrationTestFixture var act = () => sut.FindAndLoadConfigs(new ConfigFilterCriteria { - ManualConfigFiles = new[] {"manual.yml"}, - Instances = new[] {"instance1", "instance2"} + ManualConfigFiles = ["manual.yml"], + Instances = ["instance1", "instance2"] }); act.Should().ThrowExactly() @@ -91,7 +90,7 @@ public class ConfigurationRegistryTest : IntegrationTestFixture var act = () => sut.FindAndLoadConfigs(new ConfigFilterCriteria { - ManualConfigFiles = new[] {"manual.yml"} + ManualConfigFiles = ["manual.yml"] }); act.Should().ThrowExactly() @@ -127,7 +126,7 @@ public class ConfigurationRegistryTest : IntegrationTestFixture var act = () => sut.FindAndLoadConfigs(new ConfigFilterCriteria { - ManualConfigFiles = new[] {"config1.yml", "config2.yml"} + ManualConfigFiles = ["config1.yml", "config2.yml"] }); act.Should().ThrowExactly() diff --git a/tests/Recyclarr.IntegrationTests/CustomFormatLoaderIntegrationTest.cs b/tests/Recyclarr.IntegrationTests/CustomFormatLoaderIntegrationTest.cs index 0e253d21..d91d7808 100644 --- a/tests/Recyclarr.IntegrationTests/CustomFormatLoaderIntegrationTest.cs +++ b/tests/Recyclarr.IntegrationTests/CustomFormatLoaderIntegrationTest.cs @@ -25,23 +25,21 @@ public class CustomFormatLoaderIntegrationTest : IntegrationTestFixture Fs.AddFile("collection_of_cfs.md", new MockFileData("")); var dir = Fs.CurrentDirectory(); - var results = sut.LoadAllCustomFormatsAtPaths(new[] {dir}, dir.File("collection_of_cfs.md")); + var results = sut.LoadAllCustomFormatsAtPaths([dir], dir.File("collection_of_cfs.md")); - results.Should().BeEquivalentTo(new[] - { + results.Should().BeEquivalentTo([ NewCf.Data("first", "1"), NewCf.Data("second", "2") - }, o => o.Excluding(x => x.Type == typeof(JsonElement))); + ], o => o.Excluding(x => x.Type == typeof(JsonElement))); } [Test] public void Categorize_by_file_name() { var categoryParser = Resolve(); - categoryParser.Parse(default!).ReturnsForAnyArgs(new[] - { + categoryParser.Parse(default!).ReturnsForAnyArgs([ new CustomFormatCategoryItem("Streaming Services", "iTunes", "iT") - }); + ]); Fs.AddFile("it.json", new MockFileData("""{"name":"iT"}""")); Fs.AddEmptyFile("collection_of_cfs.md"); @@ -49,7 +47,7 @@ public class CustomFormatLoaderIntegrationTest : IntegrationTestFixture var sut = Resolve(); var dir = Fs.CurrentDirectory(); - var results = sut.LoadAllCustomFormatsAtPaths(new[] {dir}, dir.File("collection_of_cfs.md")); + var results = sut.LoadAllCustomFormatsAtPaths([dir], dir.File("collection_of_cfs.md")); results.Should().ContainSingle().Which.Category.Should().Be("Streaming Services"); } diff --git a/tests/Recyclarr.IntegrationTests/IncludePostProcessorIntegrationTest.cs b/tests/Recyclarr.IntegrationTests/IncludePostProcessorIntegrationTest.cs index 4bc1b22e..17317bee 100644 --- a/tests/Recyclarr.IntegrationTests/IncludePostProcessorIntegrationTest.cs +++ b/tests/Recyclarr.IntegrationTests/IncludePostProcessorIntegrationTest.cs @@ -48,10 +48,10 @@ public class IncludePostProcessorIntegrationTest : IntegrationTestFixture { ["service1"] = new() { - Include = new[] - { + Include = + [ new ConfigYamlInclude {Config = configPath.FullName} - } + ] } } }; @@ -79,10 +79,10 @@ public class IncludePostProcessorIntegrationTest : IntegrationTestFixture { ["service1"] = new() { - Include = new[] - { + Include = + [ new ConfigYamlInclude {Config = configPath.FullName} - } + ] } } }; @@ -129,22 +129,22 @@ public class IncludePostProcessorIntegrationTest : IntegrationTestFixture { BaseUrl = "the_base_url", ApiKey = "the_api_key", - CustomFormats = new[] - { + CustomFormats = + [ new CustomFormatConfigYaml { - TrashIds = new[] {"2f22d89048b01681dde8afe203bf2e95"} + TrashIds = ["2f22d89048b01681dde8afe203bf2e95"] } - }, + ], QualityDefinition = new QualitySizeConfigYaml { Type = "series" }, - Include = new[] - { + Include = + [ new ConfigYamlInclude {Config = configPath1.FullName}, new ConfigYamlInclude {Config = configPath2.FullName} - } + ] } } }; @@ -160,24 +160,24 @@ public class IncludePostProcessorIntegrationTest : IntegrationTestFixture BaseUrl = "the_base_url", ApiKey = "the_api_key", Include = null, - CustomFormats = new[] - { + CustomFormats = + [ new CustomFormatConfigYaml { - TrashIds = new[] - { + TrashIds = + [ "496f355514737f7d83bf7aa4d24f8169", "240770601cc226190c367ef59aba7463" - } + ] }, new CustomFormatConfigYaml { - TrashIds = new[] - { + TrashIds = + [ "2f22d89048b01681dde8afe203bf2e95" - } + ] } - }, + ], QualityDefinition = new QualitySizeConfigYaml { Type = "series", diff --git a/tests/Recyclarr.IntegrationTests/QualitySizeGuideParserTest.cs b/tests/Recyclarr.IntegrationTests/QualitySizeGuideParserTest.cs index 2120d3a4..9eeed532 100644 --- a/tests/Recyclarr.IntegrationTests/QualitySizeGuideParserTest.cs +++ b/tests/Recyclarr.IntegrationTests/QualitySizeGuideParserTest.cs @@ -16,20 +16,19 @@ public class QualitySizeGuideParserTest : IntegrationTestFixture var sut = Resolve(); - var result = sut.GetQualities(new[] {qualityDir}); + var result = sut.GetQualities([qualityDir]); - result.Should().BeEquivalentTo(new[] - { + result.Should().BeEquivalentTo([ new QualitySizeData { Type = "series", - Qualities = new[] - { + Qualities = + [ new QualityItem("quality1", 1, 2, 3), new QualityItem("quality2", 4.1m, 5.1m, 6.1m) - } + ] } - }); + ]); } [Test] @@ -41,7 +40,7 @@ public class QualitySizeGuideParserTest : IntegrationTestFixture var sut = Resolve(); - var result = sut.GetQualities(new[] {qualityDir}); + var result = sut.GetQualities([qualityDir]); result.Should().BeEmpty(); } diff --git a/tests/Recyclarr.Tests/Common/Extensions/FileSystemExtensionsTest.cs b/tests/Recyclarr.Tests/Common/Extensions/FileSystemExtensionsTest.cs index 10d528e0..20ff66ae 100644 --- a/tests/Recyclarr.Tests/Common/Extensions/FileSystemExtensionsTest.cs +++ b/tests/Recyclarr.Tests/Common/Extensions/FileSystemExtensionsTest.cs @@ -39,21 +39,19 @@ public class FileSystemExtensionsTest [Test] public void Merge_directories_works() { - var files = FileUtils.NormalizePaths(new[] - { + var files = FileUtils.NormalizePaths([ @"path1\1\file1.txt", @"path1\1\file2.txt", @"path1\1\2\3\4\file3.txt", @"path1\file4.txt" - }); + ]); - var dirs = FileUtils.NormalizePaths(new[] - { + var dirs = FileUtils.NormalizePaths([ @"path1\empty1", @"path1\empty2", @"path1\1\2\empty3", @"path1\1\2\3\4\empty4" - }); + ]); var fs = NewMockFileSystem(files, dirs, @"C:\root\path"); @@ -70,12 +68,11 @@ public class FileSystemExtensionsTest [Test] public void Fail_if_file_already_exists() { - var files = FileUtils.NormalizePaths(new[] - { + var files = FileUtils.NormalizePaths([ @"path1\1\file1.txt", @"path1\1\file2.txt", @"path2\1\file1.txt" - }); + ]); var fs = NewMockFileSystem(files, @"C:\root\path"); @@ -89,15 +86,13 @@ public class FileSystemExtensionsTest [Test] public void Fail_if_directory_exists_where_file_goes() { - var files = FileUtils.NormalizePaths(new[] - { + var files = FileUtils.NormalizePaths([ @"path1\1\file1" - }); + ]); - var dirs = FileUtils.NormalizePaths(new[] - { + var dirs = FileUtils.NormalizePaths([ @"path2\1\file1" - }); + ]); var fs = NewMockFileSystem(files, dirs, @"C:\root\path"); diff --git a/tests/Recyclarr.Tests/Config/ConfigExtensionsTest.cs b/tests/Recyclarr.Tests/Config/ConfigExtensionsTest.cs index eeec0107..7a12b68d 100644 --- a/tests/Recyclarr.Tests/Config/ConfigExtensionsTest.cs +++ b/tests/Recyclarr.Tests/Config/ConfigExtensionsTest.cs @@ -20,7 +20,7 @@ public class ConfigExtensionsTest var invalidInstanceNames = configs.GetInvalidInstanceNames(new ConfigFilterCriteria { - Instances = new[] {"valid_name", "invalid_name"} + Instances = ["valid_name", "invalid_name"] }); invalidInstanceNames.Should().BeEquivalentTo("invalid_name"); @@ -63,7 +63,7 @@ public class ConfigExtensionsTest var result = configs.GetConfigsBasedOnSettings(new ConfigFilterCriteria { Service = SupportedServices.Radarr, - Instances = new[] {"radarr2", "radarr4", "radarr5", "sonarr2"} + Instances = ["radarr2", "radarr4", "radarr5", "sonarr2"] }); result.Select(x => x.InstanceName).Should().BeEquivalentTo("radarr2", "radarr4"); diff --git a/tests/Recyclarr.Tests/Config/Parsing/ConfigValidationExecutorTest.cs b/tests/Recyclarr.Tests/Config/Parsing/ConfigValidationExecutorTest.cs index 2f22fc51..d4b213fb 100644 --- a/tests/Recyclarr.Tests/Config/Parsing/ConfigValidationExecutorTest.cs +++ b/tests/Recyclarr.Tests/Config/Parsing/ConfigValidationExecutorTest.cs @@ -14,10 +14,9 @@ public class ConfigValidationExecutorTest [Frozen] IRuntimeValidationService validationService, ConfigValidationExecutor sut) { - validationService.Validate(default!).ReturnsForAnyArgs(new ValidationResult(new[] - { + validationService.Validate(default!).ReturnsForAnyArgs(new ValidationResult([ new ValidationFailure("property", "message") - })); + ])); var result = sut.Validate(NewConfig.Radarr()); @@ -29,10 +28,9 @@ public class ConfigValidationExecutorTest [Frozen] IRuntimeValidationService validationService, ConfigValidationExecutor sut) { - validationService.Validate(default!).ReturnsForAnyArgs(new ValidationResult(new[] - { + validationService.Validate(default!).ReturnsForAnyArgs(new ValidationResult([ new ValidationFailure("property", "message") {Severity = Severity.Warning} - })); + ])); var result = sut.Validate(NewConfig.Radarr()); diff --git a/tests/Recyclarr.Tests/Config/Parsing/ConfigYamlDataObjectsValidationTest.cs b/tests/Recyclarr.Tests/Config/Parsing/ConfigYamlDataObjectsValidationTest.cs index 730c540b..193f1a43 100644 --- a/tests/Recyclarr.Tests/Config/Parsing/ConfigYamlDataObjectsValidationTest.cs +++ b/tests/Recyclarr.Tests/Config/Parsing/ConfigYamlDataObjectsValidationTest.cs @@ -66,10 +66,10 @@ public class ConfigYamlDataObjectsValidationTest Allowed = true, UntilQuality = "Test Quality" }, - Qualities = new[] - { + Qualities = + [ new QualityProfileQualityConfigYaml {Name = "Another Quality"} - } + ] }; var validator = new QualityProfileConfigYamlValidator(); @@ -88,8 +88,8 @@ public class ConfigYamlDataObjectsValidationTest var data = new QualityProfileConfigYaml { Name = "My QP", - Qualities = new[] - { + Qualities = + [ new QualityProfileQualityConfigYaml {Name = "Dupe Quality"}, new QualityProfileQualityConfigYaml {Name = "Dupe Quality"}, new QualityProfileQualityConfigYaml {Name = "Dupe Quality"}, @@ -98,19 +98,19 @@ public class ConfigYamlDataObjectsValidationTest new QualityProfileQualityConfigYaml { Name = "Dupe Quality 2", - Qualities = new[] {"Dupe Quality 3"} + Qualities = ["Dupe Quality 3"] }, new QualityProfileQualityConfigYaml { Name = "Dupe Quality 4", - Qualities = new[] {"Dupe Quality 5"} + Qualities = ["Dupe Quality 5"] }, new QualityProfileQualityConfigYaml { Name = "Dupe Quality 4", - Qualities = new[] {"Dupe Quality 5"} + Qualities = ["Dupe Quality 5"] } - } + ] }; var validator = new QualityProfileConfigYamlValidator(); @@ -131,11 +131,11 @@ public class ConfigYamlDataObjectsValidationTest var data = new QualityProfileConfigYaml { Name = "My QP", - Qualities = new[] - { + Qualities = + [ new QualityProfileQualityConfigYaml {Name = "Quality 1", Enabled = false}, new QualityProfileQualityConfigYaml {Name = "Quality 2", Enabled = false} - } + ] }; var validator = new QualityProfileConfigYamlValidator(); @@ -158,11 +158,11 @@ public class ConfigYamlDataObjectsValidationTest Allowed = true, UntilQuality = "Disabled Quality" }, - Qualities = new[] - { + Qualities = + [ new QualityProfileQualityConfigYaml {Name = "Enabled Quality"}, new QualityProfileQualityConfigYaml {Name = "Disabled Quality", Enabled = false} - } + ] }; var validator = new QualityProfileConfigYamlValidator(); @@ -180,14 +180,14 @@ public class ConfigYamlDataObjectsValidationTest var data = new QualityProfileConfigYaml { Name = "Profile", - Qualities = new[] - { + Qualities = + [ new QualityProfileQualityConfigYaml { Name = "Group", Qualities = Array.Empty() } - } + ] }; var validator = new QualityProfileConfigYamlValidator(); @@ -205,17 +205,17 @@ public class ConfigYamlDataObjectsValidationTest var data = new QualityProfileConfigYaml { Name = "Profile", - Qualities = new[] - { + Qualities = + [ new QualityProfileQualityConfigYaml { Name = "Group", - Qualities = new[] - { + Qualities = + [ "One Quality" - } + ] } - } + ] }; var validator = new QualityProfileConfigYamlValidator(); @@ -233,18 +233,18 @@ public class ConfigYamlDataObjectsValidationTest var data = new QualityProfileConfigYaml { Name = "Profile", - Qualities = new[] - { + Qualities = + [ new QualityProfileQualityConfigYaml { Name = "Group", - Qualities = new[] - { + Qualities = + [ "One Quality", "Two Quality" - } + ] } - } + ] }; var validator = new QualityProfileConfigYamlValidator(); diff --git a/tests/Recyclarr.Tests/Config/Parsing/PostProcessing/ConfigMerging/MergeCustomFormatsTest.cs b/tests/Recyclarr.Tests/Config/Parsing/PostProcessing/ConfigMerging/MergeCustomFormatsTest.cs index fe268158..1e4dd7a2 100644 --- a/tests/Recyclarr.Tests/Config/Parsing/PostProcessing/ConfigMerging/MergeCustomFormatsTest.cs +++ b/tests/Recyclarr.Tests/Config/Parsing/PostProcessing/ConfigMerging/MergeCustomFormatsTest.cs @@ -11,17 +11,17 @@ public class MergeCustomFormatsTest { var leftConfig = new SonarrConfigYaml { - CustomFormats = new[] - { + CustomFormats = + [ new CustomFormatConfigYaml { - TrashIds = new[] {"id1", "id2"}, - AssignScoresTo = new[] - { + TrashIds = ["id1", "id2"], + AssignScoresTo = + [ new QualityScoreConfigYaml {Name = "c", Score = 100} - } + ] } - } + ] }; var rightConfig = new SonarrConfigYaml(); @@ -40,17 +40,17 @@ public class MergeCustomFormatsTest var rightConfig = new SonarrConfigYaml { - CustomFormats = new[] - { + CustomFormats = + [ new CustomFormatConfigYaml { - TrashIds = new[] {"id1", "id2"}, - AssignScoresTo = new[] - { + TrashIds = ["id1", "id2"], + AssignScoresTo = + [ new QualityScoreConfigYaml {Name = "c", Score = 100} - } + ] } - } + ] }; var sut = new SonarrConfigMerger(); @@ -65,58 +65,58 @@ public class MergeCustomFormatsTest { var leftConfig = new SonarrConfigYaml { - CustomFormats = new[] - { + CustomFormats = + [ new CustomFormatConfigYaml { - TrashIds = new[] {"id1", "id2"}, - AssignScoresTo = new[] - { + TrashIds = ["id1", "id2"], + AssignScoresTo = + [ new QualityScoreConfigYaml {Name = "c", Score = 100}, new QualityScoreConfigYaml {Name = "d", Score = 101}, new QualityScoreConfigYaml {Name = "e", Score = 102} - } + ] }, new CustomFormatConfigYaml { - TrashIds = new[] {"id2"}, - AssignScoresTo = new[] - { + TrashIds = ["id2"], + AssignScoresTo = + [ new QualityScoreConfigYaml {Name = "f", Score = 100} - } + ] } - } + ] }; var rightConfig = new SonarrConfigYaml { - CustomFormats = new[] - { + CustomFormats = + [ new CustomFormatConfigYaml { - TrashIds = new[] {"id3", "id4"}, - AssignScoresTo = new[] - { + TrashIds = ["id3", "id4"], + AssignScoresTo = + [ new QualityScoreConfigYaml {Name = "d", Score = 200} - } + ] }, new CustomFormatConfigYaml { - TrashIds = new[] {"id5", "id6"}, - AssignScoresTo = new[] - { + TrashIds = ["id5", "id6"], + AssignScoresTo = + [ new QualityScoreConfigYaml {Name = "e", Score = 300} - } + ] }, new CustomFormatConfigYaml { - TrashIds = new[] {"id1"}, - AssignScoresTo = new[] - { + TrashIds = ["id1"], + AssignScoresTo = + [ new QualityScoreConfigYaml {Name = "c", Score = 50} - } + ] } - } + ] }; var sut = new SonarrConfigMerger(); @@ -125,65 +125,65 @@ public class MergeCustomFormatsTest result.Should().BeEquivalentTo(new SonarrConfigYaml { - CustomFormats = new[] - { + CustomFormats = + [ new CustomFormatConfigYaml { - TrashIds = new[] {"id2"}, - AssignScoresTo = new[] - { + TrashIds = ["id2"], + AssignScoresTo = + [ new QualityScoreConfigYaml {Name = "c", Score = 100} - } + ] }, new CustomFormatConfigYaml { - TrashIds = new[] {"id1", "id2"}, - AssignScoresTo = new[] - { + TrashIds = ["id1", "id2"], + AssignScoresTo = + [ new QualityScoreConfigYaml {Name = "d", Score = 101} - } + ] }, new CustomFormatConfigYaml { - TrashIds = new[] {"id1", "id2"}, - AssignScoresTo = new[] - { + TrashIds = ["id1", "id2"], + AssignScoresTo = + [ new QualityScoreConfigYaml {Name = "e", Score = 102} - } + ] }, new CustomFormatConfigYaml { - TrashIds = new[] {"id2"}, - AssignScoresTo = new[] - { + TrashIds = ["id2"], + AssignScoresTo = + [ new QualityScoreConfigYaml {Name = "f", Score = 100} - } + ] }, new CustomFormatConfigYaml { - TrashIds = new[] {"id3", "id4"}, - AssignScoresTo = new[] - { + TrashIds = ["id3", "id4"], + AssignScoresTo = + [ new QualityScoreConfigYaml {Name = "d", Score = 200} - } + ] }, new CustomFormatConfigYaml { - TrashIds = new[] {"id5", "id6"}, - AssignScoresTo = new[] - { + TrashIds = ["id5", "id6"], + AssignScoresTo = + [ new QualityScoreConfigYaml {Name = "e", Score = 300} - } + ] }, new CustomFormatConfigYaml { - TrashIds = new[] {"id1"}, - AssignScoresTo = new[] - { + TrashIds = ["id1"], + AssignScoresTo = + [ new QualityScoreConfigYaml {Name = "c", Score = 50} - } + ] } - } + ] }); } } diff --git a/tests/Recyclarr.Tests/Config/Parsing/PostProcessing/ConfigMerging/MergeQualityProfilesTest.cs b/tests/Recyclarr.Tests/Config/Parsing/PostProcessing/ConfigMerging/MergeQualityProfilesTest.cs index e517ecfb..07766873 100644 --- a/tests/Recyclarr.Tests/Config/Parsing/PostProcessing/ConfigMerging/MergeQualityProfilesTest.cs +++ b/tests/Recyclarr.Tests/Config/Parsing/PostProcessing/ConfigMerging/MergeQualityProfilesTest.cs @@ -13,8 +13,8 @@ public class MergeQualityProfilesTest { var leftConfig = new SonarrConfigYaml { - QualityProfiles = new[] - { + QualityProfiles = + [ new QualityProfileConfigYaml { Name = "e", @@ -24,7 +24,7 @@ public class MergeQualityProfilesTest ResetUnmatchedScores = new ResetUnmatchedScoresConfigYaml { Enabled = true, - Except = new[] {"except1"} + Except = ["except1"] }, Upgrade = new QualityProfileFormatUpgradeYaml { @@ -32,17 +32,17 @@ public class MergeQualityProfilesTest UntilQuality = "quality1", UntilScore = 200 }, - Qualities = new[] - { + Qualities = + [ new QualityProfileQualityConfigYaml { Enabled = true, Name = "quality1", - Qualities = new[] {"quality"} + Qualities = ["quality"] } - } + ] } - } + ] }; var rightConfig = new SonarrConfigYaml(); @@ -61,8 +61,8 @@ public class MergeQualityProfilesTest var rightConfig = new SonarrConfigYaml { - QualityProfiles = new[] - { + QualityProfiles = + [ new QualityProfileConfigYaml { Name = "e", @@ -72,7 +72,7 @@ public class MergeQualityProfilesTest ResetUnmatchedScores = new ResetUnmatchedScoresConfigYaml { Enabled = true, - Except = new[] {"except1"} + Except = ["except1"] }, Upgrade = new QualityProfileFormatUpgradeYaml { @@ -80,17 +80,17 @@ public class MergeQualityProfilesTest UntilQuality = "quality1", UntilScore = 200 }, - Qualities = new[] - { + Qualities = + [ new QualityProfileQualityConfigYaml { Enabled = true, Name = "quality1", - Qualities = new[] {"quality"} + Qualities = ["quality"] } - } + ] } - } + ] }; var sut = new SonarrConfigMerger(); @@ -106,8 +106,8 @@ public class MergeQualityProfilesTest { var leftConfig = new SonarrConfigYaml { - QualityProfiles = new[] - { + QualityProfiles = + [ new QualityProfileConfigYaml { Name = "e", @@ -117,7 +117,7 @@ public class MergeQualityProfilesTest ResetUnmatchedScores = new ResetUnmatchedScoresConfigYaml { Enabled = true, - Except = new[] {"except1"} + Except = ["except1"] }, Upgrade = new QualityProfileFormatUpgradeYaml { @@ -125,52 +125,52 @@ public class MergeQualityProfilesTest UntilQuality = "quality1", UntilScore = 200 }, - Qualities = new[] - { + Qualities = + [ new QualityProfileQualityConfigYaml { Enabled = true, Name = "quality1", - Qualities = new[] {"quality"} + Qualities = ["quality"] } - } + ] } - } + ] }; var rightConfig = new SonarrConfigYaml { - QualityProfiles = new[] - { + QualityProfiles = + [ new QualityProfileConfigYaml { Name = "e", ScoreSet = "set2", ResetUnmatchedScores = new ResetUnmatchedScoresConfigYaml { - Except = new[] {"except2", "except3"} + Except = ["except2", "except3"] }, Upgrade = new QualityProfileFormatUpgradeYaml { UntilQuality = "quality2" }, - Qualities = new[] - { + Qualities = + [ new QualityProfileQualityConfigYaml { Enabled = false, Name = "quality2", - Qualities = new[] {"quality3"} + Qualities = ["quality3"] }, new QualityProfileQualityConfigYaml { Enabled = true, Name = "quality4", - Qualities = new[] {"quality5", "quality6"} + Qualities = ["quality5", "quality6"] } - } + ] } - } + ] }; var sut = new SonarrConfigMerger(); @@ -179,8 +179,8 @@ public class MergeQualityProfilesTest result.Should().BeEquivalentTo(new SonarrConfigYaml { - QualityProfiles = new[] - { + QualityProfiles = + [ new QualityProfileConfigYaml { Name = "e", @@ -190,7 +190,7 @@ public class MergeQualityProfilesTest ResetUnmatchedScores = new ResetUnmatchedScoresConfigYaml { Enabled = true, - Except = new[] {"except1", "except2", "except3"} + Except = ["except1", "except2", "except3"] }, Upgrade = new QualityProfileFormatUpgradeYaml { @@ -198,23 +198,23 @@ public class MergeQualityProfilesTest UntilQuality = "quality2", UntilScore = 200 }, - Qualities = new[] - { + Qualities = + [ new QualityProfileQualityConfigYaml { Enabled = false, Name = "quality2", - Qualities = new[] {"quality3"} + Qualities = ["quality3"] }, new QualityProfileQualityConfigYaml { Enabled = true, Name = "quality4", - Qualities = new[] {"quality5", "quality6"} + Qualities = ["quality5", "quality6"] } - } + ] } - } + ] }); } } diff --git a/tests/Recyclarr.Tests/Config/Parsing/PostProcessing/ConfigMerging/TemplateIncludeProcessorTest.cs b/tests/Recyclarr.Tests/Config/Parsing/PostProcessing/ConfigMerging/TemplateIncludeProcessorTest.cs index 070c7102..1a4c2e80 100644 --- a/tests/Recyclarr.Tests/Config/Parsing/PostProcessing/ConfigMerging/TemplateIncludeProcessorTest.cs +++ b/tests/Recyclarr.Tests/Config/Parsing/PostProcessing/ConfigMerging/TemplateIncludeProcessorTest.cs @@ -14,15 +14,14 @@ public class TemplateIncludeProcessorTest TemplateIncludeProcessor sut) { var templatePath = fs.CurrentDirectory().File("some/path/template.yml"); - templates.GetIncludeData().Returns(new[] - { + templates.GetIncludeData().Returns([ new TemplatePath { Id = "my-template", Service = SupportedServices.Radarr, TemplateFile = templatePath } - }); + ]); var includeDirective = new TemplateYamlInclude {Template = "my-template"}; @@ -49,15 +48,14 @@ public class TemplateIncludeProcessorTest TemplateIncludeProcessor sut) { var templatePath = fs.CurrentDirectory().File("some/path/template.yml"); - templates.GetIncludeData().Returns(new[] - { + templates.GetIncludeData().Returns([ new TemplatePath { Id = "my-template", Service = SupportedServices.Radarr, TemplateFile = templatePath } - }); + ]); var includeDirective = new TemplateYamlInclude {Template = "my-template"}; @@ -73,15 +71,14 @@ public class TemplateIncludeProcessorTest TemplateIncludeProcessor sut) { var templatePath = fs.CurrentDirectory().File("some/path/template.yml"); - templates.GetIncludeData().Returns(new[] - { + templates.GetIncludeData().Returns([ new TemplatePath { Id = "my-template", Service = SupportedServices.Radarr, TemplateFile = templatePath } - }); + ]); var includeDirective = new TemplateYamlInclude {Template = "template-does-not-exist"}; diff --git a/tests/Recyclarr.Tests/Config/Parsing/YamlConfigValidatorTest.cs b/tests/Recyclarr.Tests/Config/Parsing/YamlConfigValidatorTest.cs index 9a397893..8baa0da3 100644 --- a/tests/Recyclarr.Tests/Config/Parsing/YamlConfigValidatorTest.cs +++ b/tests/Recyclarr.Tests/Config/Parsing/YamlConfigValidatorTest.cs @@ -51,7 +51,7 @@ public class YamlConfigValidatorTest { new() { - TrashIds = new[] {"valid"}, + TrashIds = ["valid"], AssignScoresTo = new List { new() @@ -84,7 +84,7 @@ public class YamlConfigValidatorTest { new() { - TrashIds = new[] {"valid"}, + TrashIds = ["valid"], AssignScoresTo = new List { new() @@ -118,7 +118,7 @@ public class YamlConfigValidatorTest { new() { - TrashIds = new[] {"valid"}, + TrashIds = ["valid"], AssignScoresTo = new List { new() diff --git a/tests/Recyclarr.Tests/Json/JsonUtilsTest.cs b/tests/Recyclarr.Tests/Json/JsonUtilsTest.cs index 8253acc8..a5c7f45d 100644 --- a/tests/Recyclarr.Tests/Json/JsonUtilsTest.cs +++ b/tests/Recyclarr.Tests/Json/JsonUtilsTest.cs @@ -15,7 +15,7 @@ public class JsonUtilsTest var path = fs.CurrentDirectory().SubDirectory("doesnt_exist"); - var result = JsonUtils.GetJsonFilesInDirectories(new[] {path}, log); + var result = JsonUtils.GetJsonFilesInDirectories([path], log); result.Should().BeEmpty(); log.Messages.Should().ContainSingle() @@ -31,7 +31,7 @@ public class JsonUtilsTest var path = fs.CurrentDirectory().SubDirectory("exists").File("test.json"); fs.AddFile(path.FullName, new MockFileData("")); - var result = JsonUtils.GetJsonFilesInDirectories(new[] {path.Directory}, log); + var result = JsonUtils.GetJsonFilesInDirectories([path.Directory], log); result.Should().ContainSingle() .Which.FullName @@ -70,7 +70,7 @@ public class JsonUtilsTest public void Null_paths_are_ignored() { var result = JsonUtils.GetJsonFilesInDirectories( - new IDirectoryInfo?[] {null, null}, + [null, null], Substitute.For()); result.Should().BeEmpty(); diff --git a/tests/Recyclarr.Tests/TrashGuide/CustomFormat/CustomFormatCategoryParserTest.cs b/tests/Recyclarr.Tests/TrashGuide/CustomFormat/CustomFormatCategoryParserTest.cs index 65656b0c..ed44824d 100644 --- a/tests/Recyclarr.Tests/TrashGuide/CustomFormat/CustomFormatCategoryParserTest.cs +++ b/tests/Recyclarr.Tests/TrashGuide/CustomFormat/CustomFormatCategoryParserTest.cs @@ -67,8 +67,7 @@ public class CustomFormatCategoryParserTest ); result.Where(x => x.CategoryName == "Audio Advanced #1").Select(x => (x.CfName, x.CfAnchor)) - .Should().BeEquivalentTo(new[] - { + .Should().BeEquivalentTo([ ("TrueHD ATMOS", "truehd-atmos"), ("DTS X", "dts-x"), ("ATMOS (undefined)", "atmos-undefined"), @@ -78,11 +77,10 @@ public class CustomFormatCategoryParserTest ("DD+", "ddplus"), ("DTS-ES", "dts-es"), ("DTS", "dts") - }); + ]); result.Where(x => x.CategoryName == "Anime").Select(x => (x.CfName, x.CfAnchor)) - .Should().BeEquivalentTo(new[] - { + .Should().BeEquivalentTo([ ("Anime Web Tier 01 (Muxers)", "anime-web-tier-01-muxers"), ("Anime Web Tier 02 (Top FanSubs)", "anime-web-tier-02-top-fansubs"), ("Anime Web Tier 03 (Official Subs)", "anime-web-tier-03-official-subs"), @@ -97,6 +95,6 @@ public class CustomFormatCategoryParserTest ("v3", "v3"), ("v4", "v4"), ("VRV", "vrv") - }); + ]); } }