You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.6 KiB
123 lines
3.6 KiB
1 year ago
|
using System.Diagnostics.CodeAnalysis;
|
||
1 year ago
|
using Recyclarr.Cli.Pipelines.QualityProfile;
|
||
2 years ago
|
using Recyclarr.Cli.Pipelines.QualityProfile.PipelinePhases;
|
||
1 year ago
|
using Recyclarr.Config.Models;
|
||
1 year ago
|
using Recyclarr.ServarrApi.QualityProfile;
|
||
2 years ago
|
|
||
1 year ago
|
namespace Recyclarr.Cli.Tests;
|
||
2 years ago
|
|
||
|
public static class NewQp
|
||
|
{
|
||
|
public static ProcessedQualityProfileData Processed(
|
||
|
string profileName,
|
||
1 year ago
|
params (string TrashId, int FormatId, int Score)[] scores)
|
||
2 years ago
|
{
|
||
1 year ago
|
return Processed(profileName, false, scores);
|
||
2 years ago
|
}
|
||
|
|
||
|
public static ProcessedQualityProfileData Processed(
|
||
|
string profileName,
|
||
1 year ago
|
bool resetUnmatchedScores,
|
||
1 year ago
|
params (string TrashId, int FormatId, int Score)[] scores)
|
||
|
{
|
||
|
return Processed(profileName, resetUnmatchedScores,
|
||
|
scores.Select(x => ("", x.TrashId, x.FormatId, x.Score)).ToArray());
|
||
|
}
|
||
|
|
||
|
public static ProcessedQualityProfileData Processed(
|
||
|
string profileName,
|
||
1 year ago
|
bool resetUnmatchedScores,
|
||
1 year ago
|
params (string CfName, string TrashId, int FormatId, int Score)[] scores)
|
||
2 years ago
|
{
|
||
1 year ago
|
var profileConfig = new QualityProfileConfig
|
||
2 years ago
|
{
|
||
1 year ago
|
Name = profileName,
|
||
1 year ago
|
ResetUnmatchedScores = new ResetUnmatchedScoresConfig
|
||
|
{
|
||
|
Enabled = resetUnmatchedScores
|
||
|
}
|
||
1 year ago
|
};
|
||
|
|
||
|
return Processed(profileConfig, scores);
|
||
|
}
|
||
|
|
||
|
public static ProcessedQualityProfileData Processed(
|
||
|
QualityProfileConfig profileConfig,
|
||
|
params (string CfName, string TrashId, int FormatId, int Score)[] scores)
|
||
|
{
|
||
|
return new ProcessedQualityProfileData
|
||
2 years ago
|
{
|
||
1 year ago
|
Profile = profileConfig,
|
||
1 year ago
|
CfScores = scores
|
||
|
.Select(x => new ProcessedQualityProfileScore(x.TrashId, x.CfName, x.FormatId, x.Score))
|
||
|
.ToList()
|
||
|
};
|
||
|
}
|
||
|
|
||
|
public static UpdatedFormatScore UpdatedScore(
|
||
|
string name,
|
||
|
int oldScore,
|
||
|
int newScore,
|
||
|
FormatScoreUpdateReason reason)
|
||
|
{
|
||
1 year ago
|
return new UpdatedFormatScore(
|
||
|
new ProfileFormatItemDto {Name = name, Score = oldScore},
|
||
|
newScore,
|
||
|
reason);
|
||
|
}
|
||
|
|
||
|
public static ProfileItemDto GroupDto(
|
||
|
int itemId,
|
||
|
string itemName,
|
||
|
bool enabled,
|
||
|
params ProfileItemDto[] nestedItems)
|
||
|
{
|
||
|
return new ProfileItemDto
|
||
|
{
|
||
|
Id = itemId,
|
||
|
Name = itemName,
|
||
|
Allowed = enabled,
|
||
|
Items = nestedItems
|
||
|
};
|
||
|
}
|
||
|
|
||
|
public static ProfileItemDto QualityDto(int itemId, string itemName, bool enabled)
|
||
|
{
|
||
|
return new ProfileItemDto
|
||
|
{
|
||
|
Allowed = enabled,
|
||
|
Quality = new ProfileItemQualityDto
|
||
|
{
|
||
|
Id = itemId,
|
||
|
Name = itemName
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
[SuppressMessage("ReSharper", "IntroduceOptionalParameters.Global", Justification =
|
||
|
"This is for unit test purposes and we want to be explicit sometimes")]
|
||
|
public static QualityProfileQualityConfig QualityConfig(string itemName)
|
||
|
{
|
||
|
return QualityConfig(itemName, true);
|
||
|
}
|
||
|
|
||
|
public static QualityProfileQualityConfig QualityConfig(string itemName, bool enabled)
|
||
|
{
|
||
|
return new QualityProfileQualityConfig
|
||
1 year ago
|
{
|
||
1 year ago
|
Enabled = enabled,
|
||
|
Name = itemName
|
||
2 years ago
|
};
|
||
|
}
|
||
1 year ago
|
|
||
|
public static QualityProfileQualityConfig GroupConfig(string itemName, params string[] nestedItems)
|
||
|
{
|
||
|
return GroupConfig(itemName, true, nestedItems);
|
||
|
}
|
||
|
|
||
|
public static QualityProfileQualityConfig GroupConfig(string itemName, bool enabled, params string[] nestedItems)
|
||
|
{
|
||
|
return QualityConfig(itemName, enabled) with {Qualities = nestedItems};
|
||
|
}
|
||
2 years ago
|
}
|