public void UnregisterToolsPath_should_do_nothing_if_tools_path_has_not_been_registered_yet() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var orgPath = Environment.GetEnvironmentVariable("Path"); var envRepos = new EnvironmentRepository(); // Act envRepos.UnregisterToolsPath(); // Assert var path = Environment.GetEnvironmentVariable("Path"); Assert.AreEqual(orgPath, path); }
public void UnregisterToolsPath_should_do_nothing_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>>(); envRepos.EnvironmentSetEnvironmentVariable = m.Object; } { var m = mocks.Create<Func<RegistryKey, string, bool, RegistryKey>>(); envRepos.RegistryKeyOpenSubKeyStringBoolean = m.Object; } { var m = mocks.Create<Action<RegistryKey, string, object>>(); envRepos.RegistryKeySetValue = m.Object; } // Act envRepos.UnregisterToolsPath(); // Assert mocks.VerifyAll(); }
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")); }