@ -2,6 +2,7 @@ using Recyclarr.Cli.Pipelines.QualityProfile;
using Recyclarr.Cli.Pipelines.QualityProfile.Api ;
using Recyclarr.Cli.Pipelines.QualityProfile.PipelinePhases ;
using Recyclarr.Cli.TestLibrary ;
using Recyclarr.TrashLib.Config.Services ;
namespace Recyclarr.Cli.Tests.Pipelines.QualityProfile.PipelinePhases ;
@ -15,11 +16,11 @@ public class QualityProfileTransactionPhaseTest
{
var guideData = new [ ]
{
NewQp . Processed ( "invalid_profile_name" , ( "id1" , 1 , 100 ) ) with
NewQp . Processed ( "invalid_profile_name" ) with
{
ShouldCreate = false
} ,
NewQp . Processed ( "profile1" , ( "id1" , 1 , 100 ) , ( "id2" , 2 , 500 ) )
NewQp . Processed ( "profile1" )
} ;
var dtos = new [ ]
@ -43,17 +44,23 @@ public class QualityProfileTransactionPhaseTest
UpdateReason = QualityProfileUpdateReason . Changed
}
}
} ,
o = > o . Excluding ( x = > x . Name . Contains ( nameof ( UpdatedQualityProfile . UpdatedScores ) ) ) ) ;
} ) ;
}
[Test, AutoMockData]
public void New_profiles (
QualityProfileTransactionPhase sut )
{
var guide Data = new [ ]
var confi gData = new [ ]
{
NewQp . Processed ( "profile1" , ( "id1" , 1 , 100 ) , ( "id2" , 2 , 500 ) )
new ProcessedQualityProfileData ( new QualityProfileConfig
{
Name = "profile1" ,
Qualities = new [ ]
{
new QualityProfileQualityConfig { Name = "quality1" , Enabled = true }
}
} )
} ;
var dtos = new [ ]
@ -61,9 +68,18 @@ public class QualityProfileTransactionPhaseTest
new QualityProfileDto { Name = "irrelevant_profile" }
} ;
var serviceData = new QualityProfileServiceData ( dtos , new QualityProfileDto ( ) ) ;
var serviceData = new QualityProfileServiceData ( dtos , new QualityProfileDto ( ) )
{
Schema = new QualityProfileDto
{
Items = new [ ]
{
new ProfileItemDto { Quality = new ProfileItemQualityDto { Name = "quality1" } }
}
}
} ;
var result = sut . Execute ( guideData , serviceData ) ;
var result = sut . Execute ( confi gData, serviceData ) ;
result . Should ( ) . BeEquivalentTo ( new QualityProfileTransactionData
{
@ -71,13 +87,27 @@ public class QualityProfileTransactionPhaseTest
{
new UpdatedQualityProfile
{
ProfileConfig = guide Data[ 0 ] ,
ProfileConfig = confi gData[ 0 ] ,
ProfileDto = serviceData . Schema ,
UpdateReason = QualityProfileUpdateReason . New
UpdateReason = QualityProfileUpdateReason . New ,
UpdatedQualities = new UpdatedQualities
{
NumWantedItems = 1 ,
Items = new [ ]
{
new ProfileItemDto
{
Allowed = true ,
Quality = new ProfileItemQualityDto
{
Name = "quality1"
}
}
} ,
o = > o . Excluding ( x = > x . Name . Contains ( nameof ( UpdatedQualityProfile . UpdatedScores ) ) ) ) ;
}
}
}
}
} ) ;
}
[Test, AutoMockData]