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); }
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); }