public void TestDebugConfiguration()
 {
     string oldSparkClrHome = SetEnviromentVariable(ConfigurationService.SPARKCLR_HOME, Path.GetTempPath());
     try
     {
         ConfigurationService debugConfiguration = new ConfigurationService();
         Assert.Throws<ConfigurationErrorsException>(() => Console.WriteLine(debugConfiguration.BackendPortNumber));
         Assert.Throws<Exception>(() => Console.WriteLine(debugConfiguration.GetCSharpWorkerExePath()));
     }
     finally
     {
         SetEnviromentVariable(ConfigurationService.SPARKCLR_HOME, oldSparkClrHome);
     }
 }
 public void TestLocalConfiguration()
 {
     string oldSparkClrHome = SetEnviromentVariable(ConfigurationService.SPARKCLR_HOME, Path.GetTempPath());
     string oldSparkMaster = SetEnviromentVariable(ConfigurationService.SPARK_MASTER, "local[3]");
     try
     {
         ConfigurationService localConfiguration = new ConfigurationService();
         Assert.IsNotNull(localConfiguration.GetCSharpWorkerExePath());
     }
     finally
     {
         SetEnviromentVariable(ConfigurationService.SPARKCLR_HOME, oldSparkClrHome);
         SetEnviromentVariable(ConfigurationService.SPARK_MASTER, oldSparkMaster);
     }
 }
        internal void TestConfiguration(string sparkMaster)
        {
            string oldSparkClrHome = SetEnviromentVariable(ConfigurationService.SPARKCLR_HOME, Path.GetTempPath());
            string oldSparkMaster = SetEnviromentVariable(ConfigurationService.SPARK_MASTER, sparkMaster);
            string oldPort = "NOT_SET";
            try
            {
                ConfigurationService localConfiguration = new ConfigurationService();
                Assert.IsNotNull(localConfiguration.GetCSharpWorkerExePath());
                Assert.Throws<Exception>(() => Console.WriteLine(localConfiguration.BackendPortNumber));
                const int backendPort = 1108;

                oldPort = SetEnviromentVariable(ConfigurationService.CSHARPBACKEND_PORT, Convert.ToString(backendPort));

                Assert.AreEqual(backendPort, localConfiguration.BackendPortNumber);
                Assert.AreEqual(ConfigurationService.ProcFileName, localConfiguration.GetCSharpWorkerExePath());
            }
            finally
            {
                SetEnviromentVariable(ConfigurationService.SPARKCLR_HOME, oldSparkClrHome);
                SetEnviromentVariable(ConfigurationService.SPARK_MASTER, oldSparkMaster);
                if (oldPort != "NOT_SET")
                {
                    SetEnviromentVariable(ConfigurationService.CSHARPBACKEND_PORT, oldPort);
                }
            }
        }