public void TestGetFilesAsync() { 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.GetFilesAsync(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); Assert.IsNotNull(response.Result.Files); Assert.AreNotEqual(response.Result.Files.Count, 0); }
public void TestGetFilesWithNullHashAsync() { UTorrentClient client = new UTorrentClient("admin", "password"); client.GetFilesAsync(null); }
public void TestGetFilesAsync() { 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.GetFilesAsync(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); Assert.IsNotNull(response.Result.Files); Assert.AreNotEqual(response.Result.Files.Count, 0); }
public void TestGetFilesWithNullHashAsync() { UTorrentClient client = new UTorrentClient("admin", "password"); Assert.ThrowsException <ArgumentNullException>(() => client.GetFilesAsync(null)); }