@ -3,7 +3,7 @@ using Recyclarr.TrashGuide.QualitySize;
namespace Recyclarr.Tests.TrashGuide.QualitySize ;
[TestFixture]
public class Quality Size ItemTest
public class Quality ItemWithPreferred Test
{
private static readonly object [ ] PreferredTestValues =
[
@ -11,10 +11,13 @@ public class QualitySizeItemTest
new object? [ ] { 100 m , 101 m , true } ,
new object? [ ] { 100 m , 98 m , true } ,
new object? [ ] { 100 m , null , true } ,
new object? [ ] { Quality Size Item. PreferredUnlimitedThreshold , null , false } ,
new object? [ ] { Quality Size Item. PreferredUnlimitedThreshold - 1 , null , true } ,
new object? [ ] { Quality ItemWithPreferred . PreferredUnlimitedThreshold , null , false } ,
new object? [ ] { Quality ItemWithPreferred . PreferredUnlimitedThreshold - 1 , null , true } ,
new object? [ ]
{ QualitySizeItem . PreferredUnlimitedThreshold , QualitySizeItem . PreferredUnlimitedThreshold , true }
{
QualityItemWithPreferred . PreferredUnlimitedThreshold , QualityItemWithPreferred . PreferredUnlimitedThreshold ,
true
}
] ;
[TestCaseSource(nameof(PreferredTestValues))]
@ -23,7 +26,7 @@ public class QualitySizeItemTest
decimal? radarrValue ,
bool isDifferent )
{
var data = new Quality Size Item( "" , 0 , 0 , guideValue ) ;
var data = new Quality ItemWithPreferred ( "" , 0 , 0 , guideValue ) ;
data . IsPreferredDifferent ( radarrValue )
. Should ( ) . Be ( isDifferent ) ;
}
@ -34,19 +37,19 @@ public class QualitySizeItemTest
{
400 m ,
1.0 m ,
Quality Size Item. PreferredUnlimitedThreshold
Quality ItemWithPreferred . PreferredUnlimitedThreshold
} ,
new [ ]
{
Quality Size Item. PreferredUnlimitedThreshold ,
Quality ItemWithPreferred . PreferredUnlimitedThreshold ,
1.0 m ,
Quality Size Item. PreferredUnlimitedThreshold
Quality ItemWithPreferred . PreferredUnlimitedThreshold
} ,
new [ ]
{
Quality Size Item. PreferredUnlimitedThreshold - 1 m ,
Quality ItemWithPreferred . PreferredUnlimitedThreshold - 1 m ,
1.0 m ,
Quality Size Item. PreferredUnlimitedThreshold - 1 m
Quality ItemWithPreferred . PreferredUnlimitedThreshold - 1 m
} ,
new [ ]
{
@ -68,54 +71,54 @@ public class QualitySizeItemTest
decimal ratio ,
decimal expectedResult )
{
var data = new Quality Size Item( "" , 0 , max , 0 ) ;
var data = new Quality ItemWithPreferred ( "" , 0 , max , 0 ) ;
data . InterpolatedPreferred ( ratio ) . Should ( ) . Be ( expectedResult ) ;
}
[Test]
public void AnnotatedPreferred_OutsideThreshold_EqualsSameValueWithUnlimited ( )
{
const decimal testVal = Quality Size Item. PreferredUnlimitedThreshold ;
var data = new Quality Size Item( "" , 0 , 0 , testVal ) ;
const decimal testVal = Quality ItemWithPreferred . PreferredUnlimitedThreshold ;
var data = new Quality ItemWithPreferred ( "" , 0 , 0 , testVal ) ;
data . AnnotatedPreferred . Should ( ) . Be ( $"{testVal} (Unlimited)" ) ;
}
[Test]
public void AnnotatedPreferred_WithinThreshold_EqualsSameStringValue ( )
{
const decimal testVal = Quality Size Item. PreferredUnlimitedThreshold - 1 ;
var data = new Quality Size Item( "" , 0 , 0 , testVal ) ;
const decimal testVal = Quality ItemWithPreferred . PreferredUnlimitedThreshold - 1 ;
var data = new Quality ItemWithPreferred ( "" , 0 , 0 , testVal ) ;
data . AnnotatedPreferred . Should ( ) . Be ( $"{testVal}" ) ;
}
[Test]
public void Preferred_AboveThreshold_EqualsSameValue ( )
{
const decimal testVal = Quality Size Item. PreferredUnlimitedThreshold + 1 ;
var data = new Quality Size Item( "" , 0 , 0 , testVal ) ;
const decimal testVal = Quality ItemWithPreferred . PreferredUnlimitedThreshold + 1 ;
var data = new Quality ItemWithPreferred ( "" , 0 , 0 , testVal ) ;
data . Preferred . Should ( ) . Be ( testVal ) ;
}
[Test]
public void PreferredForApi_AboveThreshold_EqualsNull ( )
{
const decimal testVal = Quality Size Item. PreferredUnlimitedThreshold + 1 ;
var data = new Quality Size Item( "" , 0 , 0 , testVal ) ;
const decimal testVal = Quality ItemWithPreferred . PreferredUnlimitedThreshold + 1 ;
var data = new Quality ItemWithPreferred ( "" , 0 , 0 , testVal ) ;
data . PreferredForApi . Should ( ) . Be ( null ) ;
}
[Test]
public void PreferredForApi_HighestWithinThreshold_EqualsSameValue ( )
{
const decimal testVal = Quality Size Item. PreferredUnlimitedThreshold - 0.1 m ;
var data = new Quality Size Item( "" , 0 , 0 , testVal ) ;
const decimal testVal = Quality ItemWithPreferred . PreferredUnlimitedThreshold - 0.1 m ;
var data = new Quality ItemWithPreferred ( "" , 0 , 0 , testVal ) ;
data . PreferredForApi . Should ( ) . Be ( testVal ) . And . Be ( data . Preferred ) ;
}
[Test]
public void PreferredForApi_LowestWithinThreshold_EqualsSameValue ( )
{
var data = new Quality Size Item( "" , 0 , 0 , 0 ) ;
var data = new Quality ItemWithPreferred ( "" , 0 , 0 , 0 ) ;
data . PreferredForApi . Should ( ) . Be ( 0 ) ;
}
}