public void SetEnvironmentVariable_EqualsNotValidPastFirstCharacter(string name) { // Anything past the first character in the name isn't allowed to be an equals character. // If this does change we'd need to change the logic in GetEnvironmentVariables(). Action action = () => ProcessDesktopMethods.SetEnvironmentVariable(name, "invalid"); action.ShouldThrow <ArgumentException>(); }
public void BasicGetSetEnvironmentVariable(string prefix) { string name = prefix + System.IO.Path.GetRandomFileName(); ProcessDesktopMethods.SetEnvironmentVariable(name, "BasicGetSetEnvironmentVariable"); ProcessDesktopMethods.GetEnvironmentVariable(name).Should().Be("BasicGetSetEnvironmentVariable"); ProcessDesktopMethods.SetEnvironmentVariable(name, null); ProcessDesktopMethods.GetEnvironmentVariable(name).Should().BeNull(); }
public void ValidateKnownRelativeBehaviors(string value, string expected) { // Set the current directory to D: and the hidden env for C:'s last current directory ProcessDesktopMethods.SetEnvironmentVariable(@"=C:", @"C:\Users"); using (new TempCurrentDirectory(@"D:\")) { FileMethods.GetFullPathName(value).Should().Be(expected); } }
public void ListEnvironmentVariables_Basic(string prefix) { string name = System.IO.Path.GetRandomFileName(); ProcessDesktopMethods.SetEnvironmentVariable(name, "test"); ProcessDesktopMethods.GetEnvironmentVariable(name).Should().Be("test"); var variables = ProcessDesktopMethods.GetEnvironmentVariables(); variables.Should().ContainKey(name); variables[name].Should().Be("test"); ProcessDesktopMethods.SetEnvironmentVariable(name, null); ProcessDesktopMethods.GetEnvironmentVariable(name).Should().BeNull(); variables = ProcessDesktopMethods.GetEnvironmentVariables(); variables.Should().NotContainKey(name); }
public void SetEnvironmentVariable_SetEmptyStringNotValid() { Action action = () => ProcessDesktopMethods.SetEnvironmentVariable("", "invalid"); action.ShouldThrow <ArgumentException>(); }
public void SetEnvironmentVariable_SetNullStringThrows() { Action action = () => ProcessDesktopMethods.SetEnvironmentVariable(null, "invalid"); action.ShouldThrow <ArgumentNullException>(); }