コード例 #1
0
ファイル: CSAPITests.cs プロジェクト: pjmolina/CSDotNetSDK
        public void TestHighLevel()
        {
            var goodCredentials = ReadCredentialsFromFile("..\\..\\Credentials.txt");
            Assert.IsNotNull(goodCredentials);
            var api = new CSAPIHighLevel(goodCredentials.ApiKey, goodCredentials.ApiId);

            var envStatusList = api.GetEnvironmentStatusList();
            foreach (var env in envStatusList)
            {
                Console.WriteLine(env.envId);
            }
        }
コード例 #2
0
ファイル: CSAPITests.cs プロジェクト: pjmolina/CSDotNetSDK
        public void TestHighLevelAsync()
        {
            var goodCredentials = ReadCredentialsFromFile("..\\..\\Credentials.txt");
            Assert.IsNotNull(goodCredentials);
            var api = new CSAPIHighLevel(goodCredentials.ApiKey, goodCredentials.ApiId);

            var envStatusList = api.GetEnvironmentStatusList();
            
            foreach (var env in envStatusList)
            {
                try
                {
                    var t = api.ResumeEnvironmentAsync(env);
                    t.Wait();
                    Console.WriteLine("Resumed env {0}", env.envId);
                }
                catch (AggregateException e)
                {
                    Assert.IsTrue(e.InnerException is ApiException);
                    var apiException = e.InnerException as ApiException;
                    Assert.IsTrue(apiException.ApiResponse != null, String.Format("We got Bad API Exception: {0}", apiException.Message));
                    
                    Console.WriteLine("Not expected to fail resuming env {0}.\nException message: {1}", env.envId, apiException.Message);
                }

                try
                {
                    env.envId = "NOTEXIST";
                    var t = api.ResumeEnvironmentAsync(env);
                    t.Wait();
                    Console.WriteLine("Resumed env {0}", env.envId);
                }
                catch (AggregateException e)
                {
                    Assert.IsTrue(e.InnerException is ApiException);
                    var apiException = e.InnerException as ApiException;
                    Assert.IsTrue(apiException.ApiResponse != null, String.Format("We got Bad API Exception: {0}", apiException.Message));

                    Console.WriteLine("Expected to fail resuming non existing env {0}.\nException message: {1}", env.envId, apiException.Message);
                }
            }

            envStatusList.Add(new EnvStatus());
        }