Пример #1
0
        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>();
        }
Пример #2
0
        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();
        }
Пример #3
0
 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);
     }
 }
Пример #4
0
        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);
        }
Пример #5
0
        public void SetEnvironmentVariable_SetEmptyStringNotValid()
        {
            Action action = () => ProcessDesktopMethods.SetEnvironmentVariable("", "invalid");

            action.ShouldThrow <ArgumentException>();
        }
Пример #6
0
        public void SetEnvironmentVariable_SetNullStringThrows()
        {
            Action action = () => ProcessDesktopMethods.SetEnvironmentVariable(null, "invalid");

            action.ShouldThrow <ArgumentNullException>();
        }