public void Try_Invalid_ApiKey() { try { // // Create client string invalidApiKey = "sdaf3927fnwo3022"; DisqusApiClient client = new DisqusApiClient(new Disqus.Api.V30.Authentication.DsqAuth(invalidApiKey), new Uri("http://disqus.com/", UriKind.Absolute)); // // Make request that should fail var response = client.ListPostsAsync(new List<string>(), new List<string>(new string[] { "cnn" })).Result; } catch (AggregateException ex) { foreach (var e in ex.Flatten().InnerExceptions) { if (e is DsqApiException) { DsqApiException dex = e as DsqApiException; Assert.AreEqual(dex.Code, 5, "The code in the response should be 5, indicating invalid API key. Was: " + dex.Message); } else if (e is JsonReaderException) { JsonReaderException jex = e as JsonReaderException; Assert.Fail(jex.Message + "; " + jex); } else { Assert.Fail(e.Message); } } } }
public void Posts_List() { DisqusApiClient client = new DisqusApiClient(new Disqus.Api.V30.Authentication.DsqAuth(_validApiKey), new Uri("http://disqus.com/", UriKind.Absolute)); var response = client.ListPostsAsync(new List<string>(), new List<string>(new string[] { _ownedForum })).Result; Assert.AreEqual(0, response.Code); }