public void Different_active_configuration_is_properly_used()
    {
        var steps          = Substitute.For <IPersistenceProcessorSteps>();
        var cfApi          = Substitute.For <ICustomFormatService>();
        var qpApi          = Substitute.For <IQualityProfileService>();
        var configProvider = Substitute.For <IConfigurationProvider>();

        var guideCfs          = Array.Empty <ProcessedCustomFormatData>();
        var deletedCfsInCache = Array.Empty <TrashIdMapping>();
        var profileScores     = new Dictionary <string, QualityProfileCustomFormatScoreMapping>();

        var processor = new PersistenceProcessor(cfApi, qpApi, configProvider, () => steps);

        configProvider.ActiveConfiguration = new RadarrConfiguration {
            DeleteOldCustomFormats = false
        };
        processor.PersistCustomFormats(guideCfs, deletedCfsInCache, profileScores);

        configProvider.ActiveConfiguration = new RadarrConfiguration {
            DeleteOldCustomFormats = true
        };
        processor.PersistCustomFormats(guideCfs, deletedCfsInCache, profileScores);

        steps.JsonTransactionStep.Received(1)
        .RecordDeletions(Arg.Any <IEnumerable <TrashIdMapping> >(), Arg.Any <List <JObject> >());
    }
Esempio n. 2
0
    public async Task Custom_formats_are_deleted_if_deletion_option_is_enabled_in_config()
    {
        var steps = Substitute.For <IPersistenceProcessorSteps>();
        var cfApi = Substitute.For <ICustomFormatService>();
        var qpApi = Substitute.For <IQualityProfileService>();

        var configProvider = Substitute.For <IConfigurationProvider>();

        configProvider.ActiveConfiguration = new RadarrConfiguration {
            DeleteOldCustomFormats = true
        };

        var guideCfs          = Array.Empty <ProcessedCustomFormatData>();
        var deletedCfsInCache = new Collection <TrashIdMapping>();
        var profileScores     = new Dictionary <string, QualityProfileCustomFormatScoreMapping>();

        var processor = new PersistenceProcessor(cfApi, qpApi, configProvider, () => steps);
        await processor.PersistCustomFormats(guideCfs, deletedCfsInCache, profileScores);

        steps.JsonTransactionStep.Received().RecordDeletions(Arg.Is(deletedCfsInCache), Arg.Any <List <JObject> >());
    }