style: Use collection expressions across whole solution

pull/311/head
Robert Dailey 1 month ago
parent b0c1423ee4
commit 96c3cb368e

@ -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<string>();
public string[] TemplatesOption { get; init; } = [];
public IReadOnlyCollection<string> Templates => TemplatesOption;
[CommandOption("-f|--force")]

@ -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<string>();
public string[] CustomFormatNamesOption { get; init; } = [];
public IReadOnlyCollection<string> CustomFormatNames => CustomFormatNamesOption;
[CommandOption("-a|--all")]

@ -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<string>();
public string[] ConfigsOption { get; init; } = [];
public IReadOnlyCollection<string> 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<string>();
public string[] InstancesOption { get; init; } = [];
public IReadOnlyCollection<string> Instances => InstancesOption;
}

@ -9,11 +9,11 @@ namespace Recyclarr.Cli.Migration.Steps;
public class DeleteRepoDirMigrationStep(IAppPaths paths) : IMigrationStep
{
public string Description => "Delete old repo directory";
public IReadOnlyCollection<string> Remediation => new[]
{
public IReadOnlyCollection<string> 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");

@ -13,11 +13,11 @@ public class MoveOsxAppDataDotnet8(
: IMigrationStep
{
public string Description => "Migrate OSX app data to 'Library/Application Support'";
public IReadOnlyCollection<string> Remediation => new[]
{
public IReadOnlyCollection<string> 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;

@ -9,11 +9,11 @@ namespace Recyclarr.Cli.Pipelines.CustomFormat;
public class CustomFormatPipelineContext : IPipelineContext
{
public string PipelineDescription => "Custom Format";
public IReadOnlyCollection<SupportedServices> SupportedServiceTypes { get; } = new[]
{
public IReadOnlyCollection<SupportedServices> SupportedServiceTypes { get; } =
[
SupportedServices.Sonarr,
SupportedServices.Radarr
};
];
public IList<CustomFormatData> ConfigOutput { get; init; } = [];
public IList<CustomFormatData> ApiFetchOutput { get; init; } = [];

@ -8,11 +8,11 @@ namespace Recyclarr.Cli.Pipelines.MediaNaming;
public class MediaNamingPipelineContext : IPipelineContext
{
public string PipelineDescription => "Media Naming";
public IReadOnlyCollection<SupportedServices> SupportedServiceTypes { get; } = new[]
{
public IReadOnlyCollection<SupportedServices> SupportedServiceTypes { get; } =
[
SupportedServices.Sonarr,
SupportedServices.Radarr
};
];
public ProcessedNamingConfig ConfigOutput { get; set; } = default!;
public MediaNamingDto ApiFetchOutput { get; set; } = default!;

@ -7,7 +7,7 @@ namespace Recyclarr.Cli.Pipelines.QualityProfile;
public class QualityItemOrganizer
{
private readonly List<string> _invalidItemNames = new();
private readonly List<string> _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<ProfileItemDto>();

@ -11,11 +11,11 @@ namespace Recyclarr.Cli.Pipelines.QualityProfile;
public class QualityProfilePipelineContext : IPipelineContext
{
public string PipelineDescription => "Quality Definition";
public IReadOnlyCollection<SupportedServices> SupportedServiceTypes { get; } = new[]
{
public IReadOnlyCollection<SupportedServices> SupportedServiceTypes { get; } =
[
SupportedServices.Sonarr,
SupportedServices.Radarr
};
];
public IList<ProcessedQualityProfileData> ConfigOutput { get; set; } = default!;
public QualityProfileServiceData ApiFetchOutput { get; set; } = default!;

@ -11,11 +11,11 @@ namespace Recyclarr.Cli.Pipelines.QualitySize;
public class QualitySizePipelineContext : IPipelineContext
{
public string PipelineDescription => "Quality Definition";
public IReadOnlyCollection<SupportedServices> SupportedServiceTypes { get; } = new[]
{
public IReadOnlyCollection<SupportedServices> SupportedServiceTypes { get; } =
[
SupportedServices.Sonarr,
SupportedServices.Radarr
};
];
public ProcessedQualitySizeData? ConfigOutput { get; set; }
public IList<ServiceQualityDefinitionItem> ApiFetchOutput { get; set; } = default!;

@ -158,7 +158,7 @@ public class DeleteCustomFormatsProcessor(
{
var configs = configRegistry.FindAndLoadConfigs(new ConfigFilterCriteria
{
Instances = new[] {settings.InstanceName}
Instances = [settings.InstanceName]
});
switch (configs.Count)

@ -77,7 +77,7 @@ public abstract class ServiceConfigMerger<T> 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();

@ -77,15 +77,15 @@ public sealed class GitRepository(ILogger log, IGitPath gitPath, IDirectoryInfo
var args = new List<string> {"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);
}
}

@ -11,11 +11,10 @@ internal class BaseCommandSetupIntegrationTest : CliIntegrationFixture
public void Base_command_startup_tasks_are_registered()
{
var registrations = Resolve<IEnumerable<IGlobalSetupTask>>();
registrations.Select(x => x.GetType()).Should().BeEquivalentTo(new[]
{
registrations.Select(x => x.GetType()).Should().BeEquivalentTo([
typeof(JanitorCleanupTask),
typeof(ProgramInformationDisplayTask)
});
]);
}
[Test]

@ -98,22 +98,20 @@ internal class ConfigCreationProcessorIntegrationTest : CliIntegrationFixture
Fs.AddEmptyFile(repo.Path.File("template-file3.yml"));
var settings = Substitute.For<ICreateConfigSettings>();
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<ConfigCreationProcessor>();
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
});
]);
}
}

@ -41,22 +41,20 @@ internal class TemplateConfigCreatorIntegrationTest : CliIntegrationFixture
Fs.AddEmptyFile(repo.Path.File("template-file3.yml"));
var settings = Substitute.For<ICreateConfigSettings>();
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<TemplateConfigCreator>();
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
});
]);
}
}

@ -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());
}
}

@ -87,7 +87,7 @@ public class MigrationExecutorTest
using var console = new TestConsole();
var step = Substitute.For<IMigrationStep>();
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);

@ -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);

@ -41,11 +41,10 @@ public class FieldsArrayJsonConverterTest
var result =
JsonSerializer.Deserialize<CustomFormatSpecificationData>(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<CustomFormatSpecificationData>(json, GlobalJsonSerializerSettings.Services);
result!.Fields.Should().BeEquivalentTo(new[]
{
result!.Fields.Should().BeEquivalentTo([
new CustomFormatFieldData {Value = "25"}
});
]);
}
[Test]

@ -16,11 +16,10 @@ public class CustomFormatConfigPhaseTest
var fixture = NSubstituteFixture.Create();
var guide = fixture.Freeze<ICustomFormatGuideService>();
guide.GetCustomFormatData(default!).ReturnsForAnyArgs(new[]
{
guide.GetCustomFormatData(default!).ReturnsForAnyArgs([
NewCf.Data("one", "cf1"),
NewCf.Data("two", "cf2")
});
]);
fixture.Inject<IServiceConfiguration>(NewConfig.Radarr() with
{
@ -41,11 +40,10 @@ public class CustomFormatConfigPhaseTest
var sut = fixture.Create<CustomFormatConfigPhase>();
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<ICustomFormatGuideService>();
guide.GetCustomFormatData(default!).ReturnsForAnyArgs(new[]
{
guide.GetCustomFormatData(default!).ReturnsForAnyArgs([
NewCf.Data("", "cf4")
});
]);
fixture.Inject<IServiceConfiguration>(NewConfig.Radarr() with
{

@ -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")
});
]);
}
}

@ -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<ProfileItemDto>()};

@ -24,15 +24,14 @@ public class QualityProfileConfigPhaseTest
var fixture = NSubstituteFixture.Create();
var cache = fixture.Freeze<ProcessedCustomFormatCache>();
cache.AddCustomFormats(new[]
{
cache.AddCustomFormats([
NewCf.DataWithScore("", "id1", 101, 1),
NewCf.DataWithScore("", "id2", 201, 2)
});
]);
fixture.Inject<IServiceConfiguration>(SetupCfs(new CustomFormatConfig
{
TrashIds = new[] {"id1", "id2"},
TrashIds = ["id1", "id2"],
AssignScoresTo = new List<AssignScoresToConfig>
{
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<ProcessedCustomFormatCache>();
cache.AddCustomFormats(new[]
{
cache.AddCustomFormats([
NewCf.DataWithScore("", "id1", 100, 1),
NewCf.DataWithScore("", "id2", 200, 2)
});
]);
fixture.Inject<IServiceConfiguration>(SetupCfs(new CustomFormatConfig
{
TrashIds = new[] {"id1", "id2"},
TrashIds = ["id1", "id2"],
AssignScoresTo = new List<AssignScoresToConfig>
{
new()
@ -83,10 +80,9 @@ public class QualityProfileConfigPhaseTest
var sut = fixture.Create<QualityProfileConfigPhase>();
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<ProcessedCustomFormatCache>();
cache.AddCustomFormats(new[]
{
cache.AddCustomFormats([
NewCf.Data("", "id1", 1),
NewCf.Data("", "id2", 2)
});
]);
fixture.Inject<IServiceConfiguration>(SetupCfs(new CustomFormatConfig
{
TrashIds = new[] {"id1", "id2"},
TrashIds = ["id1", "id2"],
AssignScoresTo = new List<AssignScoresToConfig>
{
new()
@ -118,10 +113,9 @@ public class QualityProfileConfigPhaseTest
var sut = fixture.Create<QualityProfileConfigPhase>();
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<ProcessedCustomFormatCache>();
cache.AddCustomFormats(new[]
{
cache.AddCustomFormats([
NewCf.DataWithScore("", "id1", 100, 1)
});
]);
fixture.Inject<IServiceConfiguration>(SetupCfs(
new CustomFormatConfig
{
TrashIds = new[] {"id1"}
TrashIds = ["id1"]
},
new CustomFormatConfig
{
TrashIds = new[] {"id1"},
TrashIds = ["id1"],
AssignScoresTo = new List<AssignScoresToConfig>
{
new() {Name = "test_profile1", Score = 100}
@ -151,7 +144,7 @@ public class QualityProfileConfigPhaseTest
},
new CustomFormatConfig
{
TrashIds = new[] {"id1"},
TrashIds = ["id1"],
AssignScoresTo = new List<AssignScoresToConfig>
{
new() {Name = "test_profile1", Score = 200}
@ -159,7 +152,7 @@ public class QualityProfileConfigPhaseTest
},
new CustomFormatConfig
{
TrashIds = new[] {"id1"},
TrashIds = ["id1"],
AssignScoresTo = new List<AssignScoresToConfig>
{
new() {Name = "test_profile2", Score = 200}
@ -167,7 +160,7 @@ public class QualityProfileConfigPhaseTest
},
new CustomFormatConfig
{
TrashIds = new[] {"id1"},
TrashIds = ["id1"],
AssignScoresTo = new List<AssignScoresToConfig>
{
new() {Name = "test_profile2", Score = 100}
@ -179,11 +172,10 @@ public class QualityProfileConfigPhaseTest
var sut = fixture.Create<QualityProfileConfigPhase>();
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<ProcessedCustomFormatCache>();
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<IServiceConfiguration>(config);
@ -227,13 +218,12 @@ public class QualityProfileConfigPhaseTest
var sut = fixture.Create<QualityProfileConfigPhase>();
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<ProcessedCustomFormatCache>();
cache.AddCustomFormats(new[]
{
cache.AddCustomFormats([
NewCf.DataWithScore("", "id1", 101, 1),
NewCf.DataWithScore("", "id2", 201, 2)
});
]);
fixture.Inject<IServiceConfiguration>(SetupCfs(new CustomFormatConfig
{
TrashIds = new[] {"id1", "id2"},
TrashIds = ["id1", "id2"],
AssignScoresTo = Array.Empty<AssignScoresToConfig>()
}));

@ -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<ProfileWithStats>
{
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"}}
}
]
}
}
};

@ -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)
});
]);
}
}

@ -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]

@ -127,10 +127,10 @@ public class UpdatedQualityProfileTest
ProfileConfig = NewQp.Processed("config_name"),
UpdatedQualities = new UpdatedQualities
{
Items = new[]
{
Items =
[
new ProfileItemDto()
}
]
},
UpdateReason = QualityProfileUpdateReason.New
};

@ -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

@ -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)
});
]);
}
}

@ -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);
}

@ -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<IConfigListTemplatesSettings>();
settings.Includes.Returns(false);

@ -29,12 +29,11 @@ public class BulkJsonLoaderIntegrationTest : IntegrationTestFixture
Fs.AddFile(Fs.CurrentDirectory().File("file.json"), new MockFileData(jsonData));
var result = sut.LoadAllFilesAtPaths<TestGuideObject>(new[] {Fs.CurrentDirectory()});
var result = sut.LoadAllFilesAtPaths<TestGuideObject>([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<TestServiceObject>(new[] {Fs.CurrentDirectory()});
var result = sut.LoadAllFilesAtPaths<TestServiceObject>([Fs.CurrentDirectory()]);
result.Should().BeEquivalentTo(new[]
{
result.Should().BeEquivalentTo([
new TestServiceObject(22, "FUNi", true)
});
]);
}
}

@ -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]

@ -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<InvalidConfigurationFilesException>();
@ -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<InvalidInstancesException>()
@ -91,7 +90,7 @@ public class ConfigurationRegistryTest : IntegrationTestFixture
var act = () => sut.FindAndLoadConfigs(new ConfigFilterCriteria
{
ManualConfigFiles = new[] {"manual.yml"}
ManualConfigFiles = ["manual.yml"]
});
act.Should().ThrowExactly<SplitInstancesException>()
@ -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<DuplicateInstancesException>()

@ -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<ICustomFormatCategoryParser>();
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<CustomFormatLoader>();
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");
}

@ -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",

@ -16,20 +16,19 @@ public class QualitySizeGuideParserTest : IntegrationTestFixture
var sut = Resolve<QualitySizeGuideParser>();
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<QualitySizeGuideParser>();
var result = sut.GetQualities(new[] {qualityDir});
var result = sut.GetQualities([qualityDir]);
result.Should().BeEmpty();
}

@ -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");

@ -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");

@ -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());

@ -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<string>()
}
}
]
};
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();

@ -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}
}
]
}
}
]
});
}
}

@ -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"]
}
}
]
}
}
]
});
}
}

@ -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"};

@ -51,7 +51,7 @@ public class YamlConfigValidatorTest
{
new()
{
TrashIds = new[] {"valid"},
TrashIds = ["valid"],
AssignScoresTo = new List<QualityScoreConfigYaml>
{
new()
@ -84,7 +84,7 @@ public class YamlConfigValidatorTest
{
new()
{
TrashIds = new[] {"valid"},
TrashIds = ["valid"],
AssignScoresTo = new List<QualityScoreConfigYaml>
{
new()
@ -118,7 +118,7 @@ public class YamlConfigValidatorTest
{
new()
{
TrashIds = new[] {"valid"},
TrashIds = ["valid"],
AssignScoresTo = new List<QualityScoreConfigYaml>
{
new()

@ -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<ILogger>());
result.Should().BeEmpty();

@ -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")
});
]);
}
}

Loading…
Cancel
Save