public void TestCheckKeys() { // good credentials var goodCredentials = ReadCredentialsFromFile("..\\..\\Credentials.txt"); Assert.IsNotNull(goodCredentials); var api = new CSAPILowLevel(goodCredentials.ApiKey, goodCredentials.ApiId); try { Assert.IsTrue(api.CheckKeys()); } catch (ApiException e) { Assert.Fail("We shouldn't get ApiException: " + e.Message); } try { var task = api.CheckKeysAsync(); task.Wait(); Assert.IsTrue(task.Result); } catch (ApiException e) { Assert.Fail("We shouldn't get ApiException: " + e.Message); } // bad credentials var badCredentials = ReadCredentialsFromFile("..\\..\\BadCredentials.txt"); Assert.IsNotNull(badCredentials); api = new CSAPILowLevel(badCredentials.ApiKey, badCredentials.ApiId); try { api.CheckKeys(); Assert.Fail("CheckKeys should throw ApiException"); } catch (ApiException e) { // we should get here Console.WriteLine(e.Message); } try { var task = api.CheckKeysAsync(); task.Wait(); Assert.Fail("CheckKeysAsync should throw ApiException"); } catch (AggregateException e) { Assert.IsTrue(e.InnerExceptions.Any(ex => ex is ApiException)); Console.WriteLine(e.InnerException.Message); } }