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.Add(new DirectoryPath("test"), null); });
        }
Esempio n. 2
0
        public void ThenTheItemIsAddedToTheEndOfThePath()
        {
            var environmentWrapper = new Mock <IEnvironmentWrapper>();

            environmentWrapper.Setup(x => x.GetEnvironmentVariable("PATH", PathTarget.Process, string.Empty)).Returns("test;test2");

            var subject = new PathWrapper(new NullLog(), environmentWrapper.Object);

            subject.Add("value", new PathSettings {
                Target = PathTarget.Process
            });

            environmentWrapper.Verify(x => x.SetEnvironmentVariable("PATH", "test;test2;value", PathTarget.Process), Times.Once);
        }
Esempio n. 3
0
        public void ThenANewPathIsAddedWithTheValue()
        {
            var environmentWrapper = new Mock <IEnvironmentWrapper>();

            environmentWrapper.Setup(x => x.GetEnvironmentVariable("PATH", PathTarget.User, string.Empty)).Returns(string.Empty);

            var subject = new PathWrapper(new NullLog(), environmentWrapper.Object);

            subject.Add(new DirectoryPath("test"), new PathSettings {
                Target = PathTarget.User
            });

            environmentWrapper.Verify(x => x.SetEnvironmentVariable("PATH", "test", PathTarget.User), Times.Once);
        }
        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.Add("value", new PathSettings {
                Target = null
            });

            environmentWrapper.Verify(x => x.SetEnvironmentVariable("PATH", "test;test2;value", PathTarget.User), Times.Once);
        }
        public void ThenThePathIsNotModified()
        {
            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.Add("test", new PathSettings {
                Target = PathTarget.Machine
            });

            environmentWrapper.Verify(x => x.SetEnvironmentVariable(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <PathTarget>()), Times.Never);
        }