Exemplo n.º 1
0
        public void Guide_processor_behaves_as_expected_with_normal_guide_data()
        {
            var ctx            = new Context();
            var guideProcessor =
                new GuideProcessor(ctx.Logger, new GithubCustomFormatJsonRequester(),
                                   () => new TestGuideProcessorSteps());

            // simulate guide data
            using var testHttp = new HttpTest();
            testHttp.RespondWithJson(new[]
            {
                new { name = "ImportableCustomFormat1.json", type = "file", download_url = "http://not_real/file.json" },
                new { name = "ImportableCustomFormat2.json", type = "file", download_url = "http://not_real/file.json" },
                new { name = "NoScore.json", type = "file", download_url = "http://not_real/file.json" },
                new { name = "WontBeInConfig.json", type = "file", download_url = "http://not_real/file.json" }
            });

            testHttp.RespondWithJson(ctx.ReadJson("ImportableCustomFormat1.json"));
            testHttp.RespondWithJson(ctx.ReadJson("ImportableCustomFormat2.json"));
            testHttp.RespondWithJson(ctx.ReadJson("NoScore.json"));
            testHttp.RespondWithJson(ctx.ReadJson("WontBeInConfig.json"));

            // Simulate user config in YAML
            var config = new List <CustomFormatConfig>
            {
                new()
                {
                    Names = new List <string> {
                        "Surround SOUND", "DTS-HD/DTS:X", "no score", "not in guide 1"
                    },
                    QualityProfiles = new List <QualityProfileConfig>
                    {
                        new() { Name = "profile1" },
                        new() { Name = "profile2", Score = -1234 }
                    }
                },
                new()
                {
                    Names = new List <string> {
                        "no score", "not in guide 2"
                    },
                    QualityProfiles = new List <QualityProfileConfig>
                    {
                        new() { Name = "profile3" },
                        new() { Name = "profile4", Score = 5678 }
                    }
                }
            };

            guideProcessor.BuildGuideData(config, null);

            var expectedProcessedCustomFormatData = new List <ProcessedCustomFormatData>
            {
                new("Surround Sound", "43bb5f09c79641e7a22e48d440bd8868", ctx.ReadJson(
                        "ImportableCustomFormat1_Processed.json"))
                {
                    Score = 500
                },
Exemplo n.º 2
0
    public async Task Guide_processor_behaves_as_expected_with_normal_guide_data()
    {
        var ctx            = new Context();
        var guideService   = Substitute.For <IRadarrGuideService>();
        var guideProcessor = new GuideProcessor(guideService, () => new TestGuideProcessorSteps());

        // simulate guide data
        guideService.GetCustomFormatJson().Returns(new[]
        {
            ctx.ReadText("ImportableCustomFormat1.json"),
            ctx.ReadText("ImportableCustomFormat2.json"),
            ctx.ReadText("NoScore.json"),
            ctx.ReadText("WontBeInConfig.json")
        });

        // Simulate user config in YAML
        var config = new List <CustomFormatConfig>
        {
            new()
            {
                Names = new List <string> {
                    "Surround SOUND", "DTS-HD/DTS:X", "no score", "not in guide 1"
                },
                QualityProfiles = new List <QualityProfileConfig>
                {
                    new() { Name = "profile1" },
                    new() { Name = "profile2", Score = -1234 }
                }
            },
            new()
            {
                Names = new List <string> {
                    "no score", "not in guide 2"
                },
                QualityProfiles = new List <QualityProfileConfig>
                {
                    new() { Name = "profile3" },
                    new() { Name = "profile4", Score = 5678 }
                }
            }
        };

        await guideProcessor.BuildGuideDataAsync(config, null);

        var expectedProcessedCustomFormatData = new List <ProcessedCustomFormatData>
        {
            new("Surround Sound", "43bb5f09c79641e7a22e48d440bd8868", ctx.ReadJson(
                    "ImportableCustomFormat1_Processed.json"))
            {
                Score = 500
            },