Beispiel #1
0
 public void Test_should_pass_when_warns_are_ignored()
 {
     Logger.Warn("I knew this would happer");
     Logger.Warn("I knew this would happer");
     Logger.Warn("I knew this would happer");
     ExceptionVerification.IgnoreWarns();
 }
Beispiel #2
0
        public void should_retry_if_interval_expired()
        {
            GivenFailedDownloadClientHistory();

            var historyGrabbed = Builder <History.History> .CreateListOfSize(1)
                                 .Build()
                                 .ToList();

            historyGrabbed.First().Data.Add("downloadClient", "SabnzbdClient");
            historyGrabbed.First().Data.Add("downloadClientId", _failed.First().DownloadClientId);
            historyGrabbed.First().Data.Add("ageHours", "1");

            GivenGrabbedHistory(historyGrabbed);
            GivenNoFailedHistory();
            GivenGracePeriod(6);
            GivenRetryLimit(1);

            Subject.Execute(new CheckForFinishedDownloadCommand());

            Subject.GetTrackedDownloads().First().LastRetry -= TimeSpan.FromMinutes(10);

            Subject.Execute(new CheckForFinishedDownloadCommand());

            VerifyRetryDownload();

            ExceptionVerification.IgnoreWarns();
        }
Beispiel #3
0
        public void should_throw_on_http429_too_many_requests()
        {
            var request = new HttpRequest($"https://{_httpBinHost}/status/429");

            Assert.Throws <TooManyRequestsException>(() => Subject.Get(request));

            ExceptionVerification.IgnoreWarns();
        }
        public void unparsable_path_should_report_the_path()
        {
            Parser.ParsePath("C:\\").Should().BeNull();

            MockedRestProvider.Verify(c => c.PostData(It.IsAny <string>(), It.IsAny <ParseErrorReport>()), Times.Exactly(2));

            ExceptionVerification.IgnoreWarns();
        }
Beispiel #5
0
        public void no_search_result(string term)
        {
            var result = Subject.SearchForNewMovie(term);

            result.Should().BeEmpty();

            ExceptionVerification.IgnoreWarns();
        }
Beispiel #6
0
        public void should_not_throw_on_suppressed_status_codes()
        {
            var request = new HttpRequest($"https://{_httpBinHost}/status/{HttpStatusCode.NotFound}");

            request.SuppressHttpErrorStatusCodes = new[] { HttpStatusCode.NotFound };

            Assert.Throws <HttpException>(() => Subject.Get <HttpBinResource>(request));

            ExceptionVerification.IgnoreWarns();
        }
Beispiel #7
0
        public void should_throw_on_unsuccessful_status_codes(int statusCode)
        {
            var request = new HttpRequest($"https://{_httpBinHost}/status/{statusCode}");

            var exception = Assert.Throws <HttpException>(() => Subject.Get <HttpBinResource>(request));

            ((int)exception.Response.StatusCode).Should().Be(statusCode);

            ExceptionVerification.IgnoreWarns();
        }
Beispiel #8
0
        public void successful_search(string title, string expected)
        {
            var result = Subject.SearchForNewMovie(title);

            result.Should().NotBeEmpty();

            result[0].Title.Should().Be(expected);

            ExceptionVerification.IgnoreWarns();
        }
        public void unparsable_title_should_report_title()
        {
            const string TITLE = "SOMETHING";

            Parser.ParseTitle(TITLE).Should().BeNull();

            MockedRestProvider.Verify(c => c.PostData(It.IsAny <string>(), It.Is <ParseErrorReport>(r => r.Title == TITLE)), Times.Once());

            ExceptionVerification.IgnoreWarns();
        }
Beispiel #10
0
        public void PathParse_tests(string path, int season, int episode)
        {
            var result = Parser.Parser.ParsePath(path);

            result.EpisodeNumbers.Should().HaveCount(1);
            result.SeasonNumber.Should().Be(season);
            result.EpisodeNumbers[0].Should().Be(episode);

            ExceptionVerification.IgnoreWarns();
        }
Beispiel #11
0
        public void should_throw_on_unsuccessful_status_codes(HttpStatusCode statusCode)
        {
            var request = new HttpRequest("http://eu.httpbin.org/status/" + (int)statusCode);

            var exception = Assert.Throws <HttpException>(() => Subject.Get <HttpBinResource>(request));

            exception.Response.StatusCode.Should().Be(statusCode);

            ExceptionVerification.IgnoreWarns();
        }
Beispiel #12
0
        public void successful_book_search(string title, int expected)
        {
            var result = Subject.Search(title);

            result.Should().NotBeEmpty();

            result[0].BookId.Should().Be(expected);

            ExceptionVerification.IgnoreWarns();
        }
Beispiel #13
0
        public void successful_book_search(string title, string author, string expected)
        {
            var result = Subject.SearchForNewBook(title, author, false);

            result.Should().NotBeEmpty();

            result[0].Editions.Value[0].Title.Should().Be(expected);

            ExceptionVerification.IgnoreWarns();
            ExceptionVerification.IgnoreErrors();
        }
Beispiel #14
0
        //        [TestCase(@"C:\CSI.NY.S02E04.720p.WEB-DL.DD5.1.H.264\73696S02-04.mkv", 2, 4)] //Gets treated as S01E04 (because it gets parsed as anime)
        public void should_parse_from_path(string path, int season, int episode)
        {
            var result = Parser.Parser.ParseMusicPath(path.AsOsAgnostic());

            //result.EpisodeNumbers.Should().HaveCount(1);
            //result.SeasonNumber.Should().Be(season);
            //result.EpisodeNumbers[0].Should().Be(episode);
            //result.AbsoluteEpisodeNumbers.Should().BeEmpty();
            //result.FullSeason.Should().BeFalse();
            ExceptionVerification.IgnoreWarns();
        }
Beispiel #15
0
        public void should_return_empty_list_on_404()
        {
            Mocker.GetMock <IHttpClient>()
            .Setup(o => o.Execute(It.Is <HttpRequest>(v => v.Method == HttpMethod.GET)))
            .Returns <HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new Byte[0], System.Net.HttpStatusCode.NotFound));

            var releases = Subject.FetchRecent();

            releases.Should().HaveCount(0);

            ExceptionVerification.IgnoreWarns();
        }
Beispiel #16
0
        public void should_parse_multi_episode_from_path(string path, string title, int season, int[] episodes)
        {
            var result = Parser.Parser.ParsePath(path.AsOsAgnostic());

            result.SeriesTitle.Should().Be(title);
            result.EpisodeNumbers.Should().HaveCount(episodes.Length);
            result.SeasonNumber.Should().Be(season);
            result.EpisodeNumbers.Should().BeEquivalentTo(episodes);
            result.AbsoluteEpisodeNumbers.Should().BeEmpty();
            result.FullSeason.Should().BeFalse();

            ExceptionVerification.IgnoreWarns();
        }
Beispiel #17
0
        public void should_continue_processing_if_not_fresh()
        {
            WithOldWrite();

            var file = Path.Combine(TempFolder, "test.avi");

            //Act
            Mocker.GetMock <SeriesProvider>().Setup(s => s.FindSeries(It.IsAny <String>())).Returns <Series>(null).Verifiable();
            Mocker.Resolve <PostDownloadProvider>().ProcessVideoFile(file);

            //Assert
            Mocker.GetMock <SeriesProvider>().Verify(s => s.FindSeries(It.IsAny <String>()), Times.Once());
            ExceptionVerification.IgnoreWarns();
        }
Beispiel #18
0
        public void should_return_if_series_is_not_found()
        {
            WithOldWrite();

            var file = Path.Combine(TempFolder, "test.avi");

            //Act
            Mocker.GetMock <SeriesProvider>().Setup(s => s.FindSeries(It.IsAny <String>())).Returns <Series>(null);
            Mocker.Resolve <PostDownloadProvider>().ProcessVideoFile(file);

            //Assert
            Mocker.GetMock <DiskProvider>().Verify(s => s.GetSize(It.IsAny <String>()), Times.Never());
            ExceptionVerification.IgnoreWarns();
        }
        public void should_search_for_series_using_title_without_status()
        {
            WithOldWrite();

            var droppedFolder = new DirectoryInfo(@"C:\Test\Unsorted TV\_unpack_The Office - S01E01 - Episode Title");

            Mocker.GetMock <SeriesProvider>().Setup(s => s.FindSeries("office")).Returns <Series>(null).Verifiable();

            //Act
            Mocker.Resolve <PostDownloadProvider>().ProcessDownload(droppedFolder);

            //Assert
            Mocker.VerifyAllMocks();
            ExceptionVerification.IgnoreWarns();
        }
        public void should_continue_processing_if_folder_is_tagged_and_not_fresh()
        {
            WithOldWrite();

            var droppedFolder = new DirectoryInfo(TempFolder + "\\_test\\");

            droppedFolder.Create();

            //Act
            Mocker.GetMock <SeriesProvider>().Setup(s => s.FindSeries(It.IsAny <String>())).Returns <Series>(null).Verifiable();
            Mocker.Resolve <PostDownloadProvider>().ProcessDownload(droppedFolder);

            //Assert
            Mocker.VerifyAllMocks();
            ExceptionVerification.IgnoreWarns();
        }
Beispiel #21
0
        public void should_move_file_if_imported()
        {
            WithLotsOfFreeDiskSpace();
            WithOldWrite();

            var file = Path.Combine(TempFolder, "test.avi");

            WithValidSeries();
            WithImportedFile(file);

            //Act
            Mocker.Resolve <PostDownloadProvider>().ProcessVideoFile(file);

            //Assert
            Mocker.GetMock <DiskScanProvider>().Verify(s => s.MoveEpisodeFile(It.IsAny <EpisodeFile>(), true), Times.Once());
            ExceptionVerification.IgnoreWarns();
        }
        public void folder_should_not_be_tagged_if_existing_tag_is_diffrent()
        {
            //Setup
            WithOldWrite();
            var droppedFolder = new DirectoryInfo(TempFolder + @"\_UnknownEpisode_The Office - S01E01 - Episode Title");

            droppedFolder.Create();
            droppedFolder.LastWriteTime = DateTime.Now.AddHours(-1);

            var taggedFolder = TempFolder + @"\_UnknownSeries_The Office - S01E01 - Episode Title";

            Mocker.GetMock <SeriesProvider>().Setup(s => s.FindSeries(It.IsAny <String>())).Returns <Series>(null);

            //Act
            Mocker.Resolve <PostDownloadProvider>().ProcessDownload(droppedFolder);

            //Assert
            Mocker.VerifyAllMocks();
            Mocker.GetMock <DiskProvider>().Verify(c => c.MoveDirectory(droppedFolder.FullName, taggedFolder), Times.Never());
            ExceptionVerification.IgnoreWarns();
        }
Beispiel #23
0
        public void should_not_process_if_age_is_less_than_grace_period()
        {
            GivenFailedDownloadClientHistory();

            var historyGrabbed = Builder <History.History> .CreateListOfSize(1)
                                 .Build()
                                 .ToList();

            historyGrabbed.First().Data.Add("downloadClient", "SabnzbdClient");
            historyGrabbed.First().Data.Add("downloadClientId", _failed.First().DownloadClientId);
            historyGrabbed.First().Data.Add("ageHours", "1");

            GivenGrabbedHistory(historyGrabbed);
            GivenNoFailedHistory();
            GivenGracePeriod(6);
            GivenRetryLimit(1);

            Subject.Execute(new CheckForFinishedDownloadCommand());

            VerifyNoFailedDownloads();
            VerifyNoRetryDownload();

            ExceptionVerification.IgnoreWarns();
        }
        public void should_not_process_if_storage_directory_in_drone_factory()
        {
            GivenCompletedDownloadClientHistory(true);

            var history = Builder <History.History> .CreateListOfSize(1)
                          .Build()
                          .ToList();

            GivenGrabbedHistory(history);
            GivenNoImportedHistory();

            Mocker.GetMock <IConfigService>()
            .SetupGet(v => v.DownloadedEpisodesFolder)
            .Returns(@"C:\DropFolder".AsOsAgnostic());

            history.First().Data.Add("downloadClient", "SabnzbdClient");
            history.First().Data.Add("downloadClientId", _completed.First().DownloadClientId);

            Subject.Execute(new CheckForFinishedDownloadCommand());

            VerifyNoImports();

            ExceptionVerification.IgnoreWarns();
        }
Beispiel #25
0
 public void TearDown()
 {
     ExceptionVerification.IgnoreWarns();
 }
 public void unparsable_should_log_error_but_not_throw(string title)
 {
     Parser.ParseTitle(title);
     ExceptionVerification.IgnoreWarns();
     ExceptionVerification.ExpectedErrors(1);
 }
 public void should_not_parse_encypted_posts(string title)
 {
     Parser.ParseTitle(title).Should().BeNull();
     ExceptionVerification.IgnoreWarns();
 }
Beispiel #28
0
        //[TestCase("___▲▲▲___")]
        //[TestCase("Add N to (X)")]
        //[TestCase("Animal Collective")]
        //[TestCase("D12")]
        //[TestCase("David Sylvian[Discography]")]
        //[TestCase("Eagle-Eye Cherry")]
        //[TestCase("Erlend Øye")]
        //[TestCase("Adult.")] // Not sure if valid, not openable in Windows OS
        //[TestCase("Maroon 5")]
        //[TestCase("Moimir Papalescu & The Nihilists")]
        //[TestCase("N.W.A")]
        //[TestCase("oOoOO")]
        //[TestCase("Panic! at the Disco")]
        //[TestCase("The 5 6 7 8's")]
        //[TestCase("tUnE-yArDs")]
        //[TestCase("U2")]
        //[TestCase("Белые Братья")]
        //[TestCase("Zog Bogbean - From The Marcy Playground")]

        // TODO: Rewrite this test to something that makes sense.
        public void should_parse_artist_names(string title)
        {
            Parser.Parser.ParseMusicTitle(title).ArtistTitle.Should().Be(title);
            ExceptionVerification.IgnoreWarns();
        }
Beispiel #29
0
        public void WithDefault_Fail()
        {
            Assert.Throws <ArgumentNullException>(() => "test".WithDefault(null));

            ExceptionVerification.IgnoreWarns();
        }
Beispiel #30
0
 public void should_not_parse_crap(string title)
 {
     Parser.Parser.ParseMovieTitle(title).Should().BeNull();
     ExceptionVerification.IgnoreWarns();
 }