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