Пример #1
0
        public void TestConsolidateTorrentWithNoTorrentInResponseResult()
        {
            BaseResponse response = new Response();

            response.Result = new Result(null);
            Assert.IsNull(UTorrentClient.ConsolidateTorrent(response, string.Empty));
        }
Пример #2
0
        public void TestGetTorrentWithFiles()
        {
            try
            {
                UTorrentClient client   = new UTorrentClient("admin", "password");
                var            response = client.GetList();
                Assert.IsNull(response.Error);
                Assert.IsNotNull(response.Result);
                Assert.IsNotNull(response.Result.Torrents);
                Assert.AreNotEqual(response.Result.Torrents.Count, 0);

                var torrent = response.Result.Torrents[0];
                response = client.GetTorrent(torrent.Hash.ToLower());
                Assert.IsNull(response.Error);
                Assert.IsNotNull(response.Result);

                torrent = UTorrentClient.ConsolidateTorrent(response, torrent.Hash);
                Assert.IsNotNull(torrent);
                Assert.IsNotNull(torrent.Files);
                Assert.AreNotEqual(torrent.Files.Count, 0);
            }
            catch (ServerUnavailableException)
            {
                Assert.Inconclusive("Serveur unavailable");
            }
            catch (InvalidCredentialException)
            {
                Assert.Inconclusive("Invalid credential");
            }
        }
Пример #3
0
        public void TestConsolidateTorrentWithNullHashParameter()
        {
            BaseResponse response = new Response();

            response.Result = new Result(null);
            UTorrentClient.ConsolidateTorrent(response, null);
        }
Пример #4
0
        public void TestConsolidateTorrentWithNullResponseResultParameter()
        {
            BaseResponse response = new Response();

            response.Result = null;
            UTorrentClient.ConsolidateTorrent(response, string.Empty);
        }
Пример #5
0
        public void TestConsolidateTorrentWithNullResponseResultParameter()
        {
            BaseResponse response = new Response();

            response.Result = null;
            Assert.ThrowsException <ArgumentNullException>(() => UTorrentClient.ConsolidateTorrent(response, string.Empty));
        }
Пример #6
0
        public void TestConsolidateTorrentWithNullHashParameter()
        {
            BaseResponse response = new Response();

            response.Result = new Result(null);
            Assert.ThrowsException <ArgumentNullException>(() => UTorrentClient.ConsolidateTorrent(response, null));
        }
Пример #7
0
        public void TestGetTorrentWithFilesAsync()
        {
            UTorrentClient  client = new UTorrentClient("admin", "password");
            Task <Response> task   = client.GetListAsync();

            try
            {
                task.Wait();
            }
            catch (AggregateException ex)
            {
                if (ex.InnerExceptions.Count == 1 &&
                    ex.InnerExceptions[0].GetType() == typeof(ServerUnavailableException))
                {
                    Assert.Inconclusive("Serveur unavailable");
                }
                if (ex.InnerExceptions.Count == 1 &&
                    ex.InnerExceptions[0].GetType() == typeof(InvalidCredentialException))
                {
                    Assert.Inconclusive("Invalid credential");
                }
            }
            var response = task.Result;

            Assert.IsNull(response.Error);
            Assert.IsNotNull(response.Result);
            Assert.IsNotNull(response.Result.Torrents);
            Assert.AreNotEqual(response.Result.Torrents.Count, 0);

            var torrent = response.Result.Torrents[0];

            task = client.GetTorrentAsync(torrent.Hash.ToLower());
            try
            {
                task.Wait();
            }
            catch (AggregateException ex)
            {
                if (ex.InnerExceptions.Count == 1 &&
                    ex.InnerExceptions[0].GetType() == typeof(ServerUnavailableException))
                {
                    Assert.Inconclusive("Serveur unavailable");
                }
                if (ex.InnerExceptions.Count == 1 &&
                    ex.InnerExceptions[0].GetType() == typeof(InvalidCredentialException))
                {
                    Assert.Inconclusive("Invalid credential");
                }
            }
            response = task.Result;
            Assert.IsNull(response.Error);
            Assert.IsNotNull(response.Result);

            torrent = UTorrentClient.ConsolidateTorrent(response, torrent.Hash);
            Assert.IsNotNull(torrent);
            Assert.IsNotNull(torrent.Files);
            Assert.AreNotEqual(torrent.Files.Count, 0);
        }
Пример #8
0
 public void TestConsolidateTorrentWithNullResponseParameter()
 {
     UTorrentClient.ConsolidateTorrent(null, string.Empty);
 }
Пример #9
0
 public void TestConsolidateTorrentWithNullResponseParameter()
 {
     Assert.ThrowsException <ArgumentNullException>(() => UTorrentClient.ConsolidateTorrent(null, string.Empty));
 }