public void ThenAnArgumentExceptionIsRaised() { var environmentWrapper = new Mock <IEnvironmentWrapper>(); environmentWrapper.Setup(x => x.GetEnvironmentVariable("PATH", PathTarget.User, string.Empty)).Returns("test"); var subject = new PathWrapper(new NullLog(), environmentWrapper.Object); Assert.Throws <ArgumentNullException>(() => { subject.Remove(new DirectoryPath("test"), null); }); }
public void ThenTheEnvironmentVariableTargetIsDefaultedToUser() { var environmentWrapper = new Mock <IEnvironmentWrapper>(); environmentWrapper.Setup(x => x.GetEnvironmentVariable("PATH", PathTarget.User, string.Empty)).Returns("test;test2"); var subject = new PathWrapper(new NullLog(), environmentWrapper.Object); subject.Remove("test", new PathSettings { Target = null }); environmentWrapper.Verify(x => x.SetEnvironmentVariable("PATH", "test2", PathTarget.User), Times.Once); }
public void ThenTheItemIsRemovedFromThePath() { var environmentWrapper = new Mock <IEnvironmentWrapper>(); environmentWrapper.Setup(x => x.GetEnvironmentVariable("PATH", PathTarget.Machine, string.Empty)).Returns("test;test2"); var subject = new PathWrapper(new NullLog(), environmentWrapper.Object); subject.Remove("test", new PathSettings { Target = PathTarget.Machine }); environmentWrapper.Verify(x => x.SetEnvironmentVariable("PATH", "test2", PathTarget.Machine), Times.Once); }
public void ThenNothingIsRemovedFromThePath() { var environmentWrapper = new Mock <IEnvironmentWrapper>(); environmentWrapper.Setup(x => x.GetEnvironmentVariable("PATH", PathTarget.Process, string.Empty)).Returns(string.Empty); var subject = new PathWrapper(new NullLog(), environmentWrapper.Object); subject.Remove(new DirectoryPath("test"), new PathSettings { Target = PathTarget.Process }); environmentWrapper.Verify(x => x.SetEnvironmentVariable(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <PathTarget>()), Times.Never); }
public void ThenThePathIsNotModified() { var environmentWrapper = new Mock <IEnvironmentWrapper>(); environmentWrapper.Setup(x => x.GetEnvironmentVariable("PATH", PathTarget.User, string.Empty)).Returns("test;test2"); var subject = new PathWrapper(new NullLog(), environmentWrapper.Object); subject.Remove("test3", new PathSettings { Target = PathTarget.User }); environmentWrapper.Verify(x => x.SetEnvironmentVariable(It.IsAny <string>(), It.IsAny <string>(), PathTarget.User), Times.Never); }