public void AddAddsArgumentWithPrefix() { var args = new SecureArguments("initial"); args.Add("value1", "p="); var expected = "initial p=value1"; var actual = args.ToString(); Assert.AreEqual(expected, actual); }
public void AddAddsArgumentWithPrefixAndDoubleQuotes() { var args = new SecureArguments("initial"); args.Add("value1", "p=", true); var expected = "initial p=\"value1\""; var actual = args.ToString(); Assert.AreEqual(expected, actual); }
public void AddIfAddsIfConditionMatches() { var args = new SecureArguments("initial"); args.AddIf(true, "value1"); var expected = "initial value1"; var actual = args.ToString(); Assert.AreEqual(expected, actual); }
public void PlusAddsArgument() { var args = new SecureArguments("initial"); args += "value1"; var expected = "initial value1"; var actual = args.ToString(); Assert.AreEqual(expected, actual); }
public void ToStringGeneratesPrivateStringInPrivateMode() { var args = new SecureArguments( new PrivateString("privateData"), "publicData"); var actual = args.ToString(SecureDataMode.Private); var expected = "privateData publicData"; Assert.AreEqual(expected, actual); }
public void ToStringGeneratesPublicString() { var args = new SecureArguments( new PrivateString("privateData"), "publicData"); var actual = args.ToString(); var expected = "privateData publicData"; Assert.AreNotEqual(expected, actual); }
/// <summary> /// Initializes a new instance of the <see cref="ProcessInfo"/> class. /// </summary> /// <param name="filename">The filename.</param> /// <param name="arguments">The arguments.</param> /// <param name="workingDirectory">The working directory.</param> /// <param name="priority">The priority.</param> /// <param name="successExitCodes">The success exit codes.</param> public ProcessInfo(string filename, SecureArguments arguments, string workingDirectory, ProcessPriorityClass priority, int[] successExitCodes) { this.arguments = arguments; this.priority = priority; startInfo.FileName = filename.StripQuotes(); startInfo.Arguments = arguments == null ? null : arguments.ToString(SecureDataMode.Private); startInfo.WorkingDirectory = workingDirectory.StripQuotes(); startInfo.UseShellExecute = false; startInfo.CreateNoWindow = true; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; startInfo.RedirectStandardInput = false; this.successExitCodes = successExitCodes ?? new[] { 0 }; }
public void ConstructorSetsProperties() { var filename = "nameoffile"; var args = new SecureArguments("value 1", new PrivateString("value 2")); var workingDirectory = "C:\\somewhere"; var priority = ProcessPriorityClass.AboveNormal; var exitCodes = new[] { 0, 1, 2, 3 }; var info = new ProcessInfo(filename, args, workingDirectory, priority, exitCodes); Assert.AreEqual(filename, info.FileName); Assert.AreSame(args, info.Arguments); var argsValue = "value 1 value 2"; Assert.AreEqual(argsValue, info.PrivateArguments); Assert.AreNotEqual(argsValue, info.PublicArguments); Assert.AreEqual(workingDirectory, info.WorkingDirectory); Assert.AreEqual(priority, info.Priority); Assert.AreEqual(exitCodes, info.SuccessExitCodes); Assert.IsNotNull(info.EnvironmentVariables); }
/// <summary> /// Initializes a new instance of the <see cref="ProcessInfo"/> class. /// </summary> /// <param name="filename">The filename.</param> /// <param name="arguments">The arguments.</param> /// <param name="workingDirectory">The working directory.</param> /// <param name="priority">The priority.</param> public ProcessInfo(string filename, SecureArguments arguments, string workingDirectory, ProcessPriorityClass priority) : this(filename, arguments, workingDirectory, priority, null) { }
/// <summary> /// Initializes a new instance of the <see cref="ProcessInfo"/> class. /// </summary> /// <param name="filename">The filename.</param> /// <param name="arguments">The arguments.</param> /// <param name="workingDirectory">The working directory.</param> public ProcessInfo(string filename, SecureArguments arguments, string workingDirectory) : this(filename, arguments, workingDirectory, DefaultPriority) { }
/// <summary> /// Initializes a new instance of the <see cref="ProcessInfo"/> class. /// </summary> /// <param name="filename">The filename.</param> /// <param name="arguments">The arguments.</param> public ProcessInfo(string filename, SecureArguments arguments) : this(filename, arguments, null) { }
public void AddIfDoesNotAddWithConditionMismatch() { var args = new SecureArguments("initial"); args.AddIf(false, "value1"); var expected = "initial"; var actual = args.ToString(); Assert.AreEqual(expected, actual); }
public void ConstructorAddsArguments() { var args = new SecureArguments("Test", 2); Assert.AreEqual(2, args.Count); }
public void AddIfHandlesPrefixAndQuotes() { var args = new SecureArguments("initial"); args.AddIf(true, "value1", "p=", true); var expected = "initial p=\"value1\""; var actual = args.ToString(); Assert.AreEqual(expected, actual); }
/// <summary> /// Initialises the process. /// </summary> /// <returns> /// The information for the process. /// </returns> private ProcessInfo InitialiseProcess() { var args = new SecureArguments(); args.Add(this.ProjectFile); return new ProcessInfo( this.Executable ?? DefaultExecutable, args, Environment.CurrentDirectory); }