Ejemplo n.º 1
0
        public void TestEnricherMethods()
        {
            var tvDbService = new TvDbService(Config.Instance.CacheFolder, Config.Instance.ApiKey);
            var enricher    = new TvdbLibAccess(Config.Instance, EpisodeMatchMethodLoader.GetMatchMethods(), tvDbService);

            this.CreateTestData();

            bool pass = true;

            foreach (var testProgram in this.testPrograms)
            {
                try
                {
                    var series = enricher.GetTvdbSeries(enricher.getSeriesId(testProgram.Title), false);
                    enricher.EnrichProgram(testProgram, series);
                    if (testProgram.EpisodeNumberDisplay == testProgram.ExpectedEpisodeNumberDisplay)
                    {
                        Console.WriteLine(string.Format(CultureInfo.CurrentCulture, "Correctly matched {0} - {1}", testProgram.Title, testProgram.EpisodeNumberDisplay));
                    }
                    else
                    {
                        Console.WriteLine(string.Format(CultureInfo.CurrentCulture, "Unable to match {0} - {1}", testProgram.Title, testProgram.SubTitle));
                        pass = false;
                    }
                }
                catch (Exception exception)
                {
                    pass = false;
                    Console.WriteLine(string.Format(CultureInfo.CurrentCulture, "Couldn't match {0} - {1}", testProgram.Title, testProgram.SubTitle));
                    Console.WriteLine(exception.Message);
                }
            }
            //
            Assert.True(pass, "Test failed!");
        }
        public void TestEnricherMethods()
        {
            var tvDbService = new TvDbService(Config.Instance.CacheFolder, Config.Instance.ApiKey);
            var enricher = new TvdbLibAccess(Config.Instance, EpisodeMatchMethodLoader.GetMatchMethods(), tvDbService);
            this.CreateTestData();

            bool pass = true;
            foreach (var testProgram in this.testPrograms)
            {
                try
                {
                    var series = enricher.GetTvdbSeries(enricher.getSeriesId(testProgram.Title), false);
                    enricher.EnrichProgram(testProgram, series);
                    if (testProgram.EpisodeNumberDisplay == testProgram.ExpectedEpisodeNumberDisplay)
                    {
                        Console.WriteLine(string.Format(CultureInfo.CurrentCulture, "Correctly matched {0} - {1}", testProgram.Title, testProgram.EpisodeNumberDisplay));
                    }
                    else
                    {
                        Console.WriteLine(string.Format(CultureInfo.CurrentCulture, "Unable to match {0} - {1}", testProgram.Title, testProgram.SubTitle));
                        pass = false;
                    }

                }
                catch (Exception exception)
                {
                    pass = false;
                    Console.WriteLine(string.Format(CultureInfo.CurrentCulture, "Couldn't match {0} - {1}", testProgram.Title, testProgram.SubTitle));
                    Console.WriteLine(exception.Message);
                }
            }
            //
            Assert.True(pass, "Test failed!");
        }
Ejemplo n.º 3
0
        public void TestMappingNameWithID()
        {
            var lawOrderProgram = new TestProgram("Law & Order: Special Victims Unit", "Identity", 0, "S06E12");
            var seriesNameMap   = new Dictionary <string, string>(1);

            seriesNameMap.Add("Law & Order: Special Victims Unit", "id=75692");
            var mockConfig = new Moq.Mock <IConfiguration>();

            mockConfig.Setup(x => x.getSeriesNameMap()).Returns(seriesNameMap);
            var tvDbApi  = new TvDbService(GetWorkingDirectory(), Config.Instance.ApiKey);
            var enricher = new TvdbLibAccess(mockConfig.Object, EpisodeMatchMethodLoader.GetMatchMethods(), tvDbApi);
            var series   = enricher.GetTvdbSeries(enricher.getSeriesId(lawOrderProgram.Title), false);

            enricher.EnrichProgram(lawOrderProgram, series);
            Assert.True(lawOrderProgram.EpisodeIsEnriched());
        }
Ejemplo n.º 4
0
        public void TestMappingRegex()
        {
            var lawOrderProgram = new TestProgram("Stargate Atlantis123", "Common Ground", 0, "S03E07");
            var seriesNameMap   = new Dictionary <string, string>(1);

            seriesNameMap.Add("regex=Stargate Atl.*", "Stargate Atlantis");
            var mockConfig = new Moq.Mock <IConfiguration>();

            mockConfig.Setup(x => x.getSeriesNameMap()).Returns(seriesNameMap);
            var tvDbApi  = new TvDbService(GetWorkingDirectory(), Config.Instance.ApiKey);
            var enricher = new TvdbLibAccess(mockConfig.Object, EpisodeMatchMethodLoader.GetMatchMethods(), tvDbApi);
            var series   = enricher.GetTvdbSeries(enricher.getSeriesId(lawOrderProgram.Title), false);

            enricher.EnrichProgram(lawOrderProgram, series);
            Assert.True(lawOrderProgram.EpisodeIsEnriched());
        }
Ejemplo n.º 5
0
        public void TestBlackSails()
        {
            // Arrange
            var program       = new TestProgram("Black Sails", "XVIII.", 0, "S02E10");
            var seriesNameMap = new Dictionary <string, string>(1);
            //seriesNameMap.Add("Blue Bloods", "id=164981");
            var mockConfig = new Moq.Mock <IConfiguration>();

            mockConfig.Setup(x => x.getSeriesNameMap()).Returns(seriesNameMap);
            mockConfig.Setup(x => x.UpdateMatchedEpisodes).Returns(true);
            mockConfig.Setup(x => x.UpdateSubtitlesParameter).Returns(true);
            mockConfig.Setup(x => x.GetProperty(Moq.It.Is <string>((c) => c == "TvDbLanguage"))).Returns("en");
            var tvDbApi  = new TvDbService(GetWorkingDirectory(), Config.Instance.ApiKey);
            var enricher = new TvdbLibAccess(mockConfig.Object, EpisodeMatchMethodLoader.GetMatchMethods(), tvDbApi);
            var series   = enricher.GetTvdbSeries(enricher.getSeriesId(program.Title), false);

            // Act
            enricher.EnrichProgram(program, series);
            // Assert
            program.Assert();
        }
Ejemplo n.º 6
0
        public void TestAgathaChristiesMarple()
        {
            // Arrange
            var program       = new TestProgram("Agatha Christie's Marple", "Murder at the Vicarage", 0, "S01E02");
            var seriesNameMap = new Dictionary <string, string>(1);

            seriesNameMap.Add("Agatha Christie's Marple", "id=78895");
            var mockConfig = new Moq.Mock <IConfiguration>();

            mockConfig.Setup(x => x.getSeriesNameMap()).Returns(seriesNameMap);
            mockConfig.Setup(x => x.UpdateMatchedEpisodes).Returns(true);
            mockConfig.Setup(x => x.UpdateSubtitlesParameter).Returns(true);
            var tvDbApi  = new TvDbService(GetWorkingDirectory(), Config.Instance.ApiKey);
            var enricher = new TvdbLibAccess(mockConfig.Object, EpisodeMatchMethodLoader.GetMatchMethods(), tvDbApi);
            var series   = enricher.GetTvdbSeries(enricher.getSeriesId(program.Title), false);

            // Act
            enricher.EnrichProgram(program, series);
            // Assert
            program.Assert();
        }
 public void TestMappingNameWithID()
 {
     var lawOrderProgram = new TestProgram("Law & Order: Special Victims Unit", "Identity", 0, "S06E12");
     var seriesNameMap = new Dictionary<string, string>(1);
     seriesNameMap.Add("Law & Order: Special Victims Unit", "id=75692");
     var mockConfig = new Moq.Mock<IConfiguration>();
     mockConfig.Setup(x => x.getSeriesNameMap()).Returns(seriesNameMap);
     var tvDbApi = new TvDbService(GetWorkingDirectory(), Config.Instance.ApiKey);
     var enricher = new TvdbLibAccess(mockConfig.Object, EpisodeMatchMethodLoader.GetMatchMethods(), tvDbApi);
     var series = enricher.GetTvdbSeries(enricher.getSeriesId(lawOrderProgram.Title), false);
     enricher.EnrichProgram(lawOrderProgram, series);
     Assert.True(lawOrderProgram.EpisodeIsEnriched());
 }
 public void TestBlackSails()
 {
     // Arrange
     var program = new TestProgram("Black Sails", "XVIII.", 0, "S02E10");
     var seriesNameMap = new Dictionary<string, string>(1);
     //seriesNameMap.Add("Blue Bloods", "id=164981");
     var mockConfig = new Moq.Mock<IConfiguration>();
     mockConfig.Setup(x => x.getSeriesNameMap()).Returns(seriesNameMap);
     mockConfig.Setup(x => x.UpdateMatchedEpisodes).Returns(true);
     mockConfig.Setup(x => x.UpdateSubtitlesParameter).Returns(true);
     mockConfig.Setup(x => x.GetProperty(Moq.It.Is<string>((c) => c == "TvDbLanguage"))).Returns("en");
     var tvDbApi = new TvDbService(GetWorkingDirectory(), Config.Instance.ApiKey);
     var enricher = new TvdbLibAccess(mockConfig.Object, EpisodeMatchMethodLoader.GetMatchMethods(), tvDbApi);
     var series = enricher.GetTvdbSeries(enricher.getSeriesId(program.Title), false);
     // Act
     enricher.EnrichProgram(program, series);
     // Assert
     program.Assert();
 }        
 public void TestAgathaChristiesMarple()
 {
     // Arrange
     var program = new TestProgram("Agatha Christie's Marple", "Murder at the Vicarage", 0, "S01E02");
     var seriesNameMap = new Dictionary<string, string>(1);
     seriesNameMap.Add("Agatha Christie's Marple", "id=78895");
     var mockConfig = new Moq.Mock<IConfiguration>();
     mockConfig.Setup(x => x.getSeriesNameMap()).Returns(seriesNameMap);
     mockConfig.Setup(x => x.UpdateMatchedEpisodes).Returns(true);
     mockConfig.Setup(x => x.UpdateSubtitlesParameter).Returns(true);
     var tvDbApi = new TvDbService(GetWorkingDirectory(), Config.Instance.ApiKey);
     var enricher = new TvdbLibAccess(mockConfig.Object, EpisodeMatchMethodLoader.GetMatchMethods(), tvDbApi);
     var series = enricher.GetTvdbSeries(enricher.getSeriesId(program.Title), false);
     // Act
     enricher.EnrichProgram(program, series);
     // Assert
     program.Assert();
 }
 public void TestRegularMapping()
 {
     var lawOrderProgram = new TestProgram("Stargate Atlantis123", "Common Ground", 0, "S03E07");
     var seriesNameMap = new Dictionary<string, string>(1);
     seriesNameMap.Add("Stargate Atlantis123", "Stargate Atlantis");
     var mockConfig = new Moq.Mock<IConfiguration>();
     mockConfig.Setup(x => x.getSeriesNameMap()).Returns(seriesNameMap);
     //
     var tvDbApi = new TvDbService(GetWorkingDirectory(), Config.Instance.ApiKey);
     var enricher = new TvdbLibAccess(mockConfig.Object, EpisodeMatchMethodLoader.GetMatchMethods(), tvDbApi);
     var series = enricher.GetTvdbSeries(enricher.getSeriesId(lawOrderProgram.Title), false);
     enricher.EnrichProgram(lawOrderProgram, series);
     Assert.True(lawOrderProgram.EpisodeIsEnriched());
 }