public void UnregisterToolsPath_should_remove_tools_path_from_environment_variable()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoMoqCustomization());

            var envRepos = new EnvironmentRepository();
            envRepos.RegisterToolsPath();


            // Act
            envRepos.UnregisterToolsPath();


            // Assert
            var path = Environment.GetEnvironmentVariable("Path");
            Assert.That(path, Is.Not.StringContaining(@";C:\ProgramData\chocolatey\lib\Prig\tools"));
        }
        public void RegisterToolsPath_should_set_tools_path_even_if_path_environment_variable_was_null()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoMoqCustomization());

            var envRepos = new EnvironmentRepository();
            var mocks = new MockRepository(MockBehavior.Strict);
            {
                var m = mocks.Create<Func<string, EnvironmentVariableTarget, string>>();
                m.Setup(_ => _("ALLUSERSPROFILE", EnvironmentVariableTarget.Process)).Returns(@"C:\ProgramData");
                m.Setup(_ => _("Path", EnvironmentVariableTarget.Process)).Returns(default(string));
                m.Setup(_ => _("Path", EnvironmentVariableTarget.Machine)).Returns(default(string));
                envRepos.EnvironmentGetEnvironmentVariable = m.Object;
            }
            {
                var m = mocks.Create<Action<string, string, EnvironmentVariableTarget>>();
                m.Setup(_ => _("Path", @"C:\ProgramData\chocolatey\lib\Prig\tools", EnvironmentVariableTarget.Process));
                envRepos.EnvironmentSetEnvironmentVariable = m.Object;
            }
            {
                var m = mocks.Create<Func<RegistryKey, string, bool, RegistryKey>>();
                m.Setup(_ => _(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", true)).Returns(RegistryKeyMixin.DummyEnvironmentKey);
                envRepos.RegistryKeyOpenSubKeyStringBoolean = m.Object;
            }
            {
                var m = mocks.Create<Action<RegistryKey, string, object>>();
                m.Setup(_ => _(RegistryKeyMixin.DummyEnvironmentKey, "Path", @"C:\ProgramData\chocolatey\lib\Prig\tools"));
                envRepos.RegistryKeySetValue = m.Object;
            }


            // Act
            envRepos.RegisterToolsPath();


            // Assert
            mocks.VerifyAll();
        }