Example #1
0
        public void DownloadCaseInvalidTorrent()
        {
            downloadMethod =
                new P2PDownloadMethod(logger.Object, settingsMock.Object, ariaService.Object, torrentService.Object);

            var item = new DownloadItem
            {
                FileUrl = "http://invalid-torrent-url.com/file.torrent"
            };

            var ex = Assert.Throws <FileNotDownloadableException>(() => downloadMethod.Start(item));

            Assert.AreEqual(P2PDownloadMethod.TorrentFileNotFoundMessage, ex.Message);
        }
Example #2
0
        public void DownloadCaseCorruptedTorrent()
        {
            downloadMethod =
                new P2PDownloadMethod(logger.Object, settingsMock.Object, ariaService.Object, torrentService.Object);

            var corruptedTorrentPath =
                TestHelper.GetRessourceFullPath("The.Big.Bang.Theory.S11E14.HDTV.x264-SVA[rarbg].corrupted.torrent");
            var item = new DownloadItem
            {
                FileUrl = corruptedTorrentPath
            };
            var ex = Assert.Throws <FileNotDownloadableException>(() => downloadMethod.Start(item));

            Assert.AreEqual(P2PDownloadMethod.TorrentFileCorrupted, ex.Message);
        }
Example #3
0
        public void DownloadCaseInvalidMagnet(string magnetLink, string expectedExceptionMessage, int ariaReturnValue)
        {
            var item = new DownloadItem {
                FileUrl = magnetLink
            };

            ariaService
            .Setup(x => x.DownloadTorrentFile(It.Is <string>(url => url == magnetLink), It.IsAny <string>(), It.IsAny <TimeSpan>()))
            .Returns(ariaReturnValue);
            downloadMethod =
                new P2PDownloadMethod(logger.Object, settingsMock.Object, ariaService.Object, torrentService.Object);

            var ex = Assert.Throws <FileNotDownloadableException>(() => downloadMethod.Start(item));

            Assert.AreEqual(expectedExceptionMessage, ex.Message);
        }
Example #4
0
        public void DownloadCaseFailedToAddTorrentToDaemon()
        {
            torrentService.Setup(x => x.AddTorrent(It.IsAny <string>(), It.IsAny <string>())).Returns(false);
            downloadMethod =
                new P2PDownloadMethod(logger.Object, settingsMock.Object, ariaService.Object, torrentService.Object);

            var torrentPath =
                TestHelper.GetRessourceFullPath("The.Big.Bang.Theory.S11E14.HDTV.x264-SVA[rarbg].torrent");

            var item = new DownloadItem
            {
                FileUrl = torrentPath
            };

            var ex = Assert.Throws <StartDownloadException>(() => downloadMethod.Start(item));

            Assert.AreEqual(P2PDownloadMethod.TorrentDaemonAddFailureMessage, ex.Message);
        }
Example #5
0
        public void DownloadCaseValid()
        {
            torrentService.Setup(x => x.AddTorrent(It.IsAny <string>(), It.IsAny <string>())).Returns(true);
            downloadMethod =
                new P2PDownloadMethod(logger.Object, settingsMock.Object, ariaService.Object, torrentService.Object);

            var torrentPath =
                TestHelper.GetRessourceFullPath("The.Big.Bang.Theory.S11E14.HDTV.x264-SVA[rarbg].torrent");

            var item = new DownloadItem
            {
                FileUrl = torrentPath
            };

            Assert.DoesNotThrow(() => downloadMethod.Start(item));
            Assert.AreEqual("The.Big.Bang.Theory.S11E14.HDTV.x264-SVA[rarbg]", item.Name);
            Assert.AreEqual(140940255, item.TotalSize);
            Assert.AreEqual("25c8f093021fd9d97087f9444c160d9bb3d70e35", item.Hash);
        }