public void SystemLevelEnvironmentVariable() { EnvironmentPatternConverter converter = new EnvironmentPatternConverter(); try { Environment.SetEnvironmentVariable(ENVIRONMENT_VARIABLE_NAME, SYSTEM_LEVEL_VALUE, EnvironmentVariableTarget.Machine); } catch (System.Security.SecurityException) { Assert.Ignore("Test skipped as current user must not set system level environment variables"); } converter.Option = ENVIRONMENT_VARIABLE_NAME; StringWriter sw = new StringWriter(); converter.Convert(sw, null); sw.Close(); try { Assert.AreEqual(SYSTEM_LEVEL_VALUE, sw.ToString(), string.Format("Process level environment variable not expanded correctly. Found {0}" , Dump(Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine)))); } finally { Environment.SetEnvironmentVariable(ENVIRONMENT_VARIABLE_NAME, null, EnvironmentVariableTarget.Machine); } }
public void SystemLevelEnvironmentVariable() { EnvironmentPatternConverter converter = new EnvironmentPatternConverter(); try { Environment.SetEnvironmentVariable(ENVIRONMENT_VARIABLE_NAME, SYSTEM_LEVEL_VALUE, EnvironmentVariableTarget.Machine); } catch (System.Security.SecurityException) { Assert.Ignore("Test skipped as current user must not set system level environment variables"); } converter.Option = ENVIRONMENT_VARIABLE_NAME; StringWriter sw = new StringWriter(); converter.Convert(sw, null); sw.Close(); try { Assert.AreEqual(SYSTEM_LEVEL_VALUE, sw.ToString(), string.Format("Process level environment variable not expanded correctly. Found {0}", Dump(Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine)))); } finally { Environment.SetEnvironmentVariable(ENVIRONMENT_VARIABLE_NAME, null, EnvironmentVariableTarget.Machine); } }
public void UserLevelEnvironmentVariable() { EnvironmentPatternConverter converter = new EnvironmentPatternConverter(); Environment.SetEnvironmentVariable(ENVIRONMENT_VARIABLE_NAME, USER_LEVEL_VALUE, EnvironmentVariableTarget.User); converter.Option = ENVIRONMENT_VARIABLE_NAME; StringWriter sw = new StringWriter(); converter.Convert(sw, null); Assert.AreEqual(USER_LEVEL_VALUE, sw.ToString(), "User level environment variable not expended correctly."); Environment.SetEnvironmentVariable(ENVIRONMENT_VARIABLE_NAME, null, EnvironmentVariableTarget.User); }
public void ProcessLevelEnvironmentVariable() { EnvironmentPatternConverter converter = new EnvironmentPatternConverter(); Environment.SetEnvironmentVariable(ENVIRONMENT_VARIABLE_NAME, PROCESS_LEVEL_VALUE); converter.Option = ENVIRONMENT_VARIABLE_NAME; StringWriter sw = new StringWriter(); converter.Convert(sw, null); Assert.AreEqual(PROCESS_LEVEL_VALUE, sw.ToString(), "Process level environment variable not expended correctly."); Environment.SetEnvironmentVariable(ENVIRONMENT_VARIABLE_NAME, null); }
public void SystemLevelEnvironmentVariable() { EnvironmentPatternConverter converter = new EnvironmentPatternConverter(); try { Environment.SetEnvironmentVariable(ENVIRONMENT_VARIABLE_NAME, SYSTEM_LEVEL_VALUE, EnvironmentVariableTarget.Machine); } catch (System.Security.SecurityException) { Assert.Ignore("Test skipped as current user must not set system level environment variables"); } converter.Option = ENVIRONMENT_VARIABLE_NAME; StringWriter sw = new StringWriter(); converter.Convert(sw, null, null); Assert.AreEqual(SYSTEM_LEVEL_VALUE, sw.ToString(), "System level environment variable not expended correctly."); Environment.SetEnvironmentVariable(ENVIRONMENT_VARIABLE_NAME, null, EnvironmentVariableTarget.Machine); }
public void UserLevelEnvironmentVariable() { EnvironmentPatternConverter converter = new EnvironmentPatternConverter(); Environment.SetEnvironmentVariable(ENVIRONMENT_VARIABLE_NAME, USER_LEVEL_VALUE, EnvironmentVariableTarget.User); converter.Option = ENVIRONMENT_VARIABLE_NAME; StringWriter sw = new StringWriter(); converter.Convert(sw, null); sw.Close(); try { Assert.AreEqual(USER_LEVEL_VALUE, sw.ToString(), string.Format("Process level environment variable not expanded correctly. Found {0}" , Dump(Environment.GetEnvironmentVariables(EnvironmentVariableTarget.User)))); } finally { Environment.SetEnvironmentVariable(ENVIRONMENT_VARIABLE_NAME, null, EnvironmentVariableTarget.User); } }
public void ProcessLevelEnvironmentVariable() { EnvironmentPatternConverter converter = new EnvironmentPatternConverter(); Environment.SetEnvironmentVariable(ENVIRONMENT_VARIABLE_NAME, PROCESS_LEVEL_VALUE); converter.Option = ENVIRONMENT_VARIABLE_NAME; StringWriter sw = new StringWriter(); converter.Convert(sw, null); sw.Close(); try { Assert.AreEqual(PROCESS_LEVEL_VALUE, sw.ToString(), string.Format("Process level environment variable not expanded correctly. Found {0}", Dump(Environment.GetEnvironmentVariables()))); } finally { Environment.SetEnvironmentVariable(ENVIRONMENT_VARIABLE_NAME, null); } }