private void SetOptionsFromArguments(string[] args) { try { WPP.Tools.CommandLine commandLine = new WPP.Tools.CommandLine(args); if (commandLine.OptionExists("Server")) { this.txtBxWsusServer.Text = commandLine.GetOptionValue <string>("Server", String.Empty); this.txtBxWsusServer.BackColor = SystemColors.Control; } else { this.txtBxWsusServer.Text = String.Empty; this.txtBxWsusServer.BackColor = System.Drawing.Color.Bisque; } if (commandLine.OptionExists("Port")) { this.nupServerPort.Value = commandLine.GetOptionValue <Decimal>("Port", 8530); this.nupServerPort.BackColor = SystemColors.Control; } else { this.nupServerPort.Value = (Decimal)8530; this.nupServerPort.BackColor = System.Drawing.Color.Bisque; } if (commandLine.OptionExists("SSL")) { this.chkBxUseSSL.Checked = commandLine.GetOptionValue <Boolean>("SSL", false); this.chkBxUseSSL.BackColor = SystemColors.Control; } else { this.chkBxUseSSL.Checked = false; this.chkBxUseSSL.BackColor = System.Drawing.Color.Bisque; } if (commandLine.OptionExists("Login")) { this.txtBxCredentials.Text = commandLine.GetOptionValue <string>("Login", String.Empty); this.txtBxCredentials.BackColor = SystemColors.Control; } else { this.txtBxCredentials.Text = String.Empty; this.txtBxCredentials.BackColor = System.Drawing.Color.Bisque; } } catch (Exception ex) { MessageBox.Show(this._localization.GetLocalizedString("AnErrorOccursWhileParsingTheCommandLine") + "\r\n" + ex.Message); } }
public void ReturnTheDefaultValue_WhenCallingWithAnArgumentWithoutValue() { // Arrange SUT commandLine = new SUT(_argWithoutValue); // Assert Assert.AreEqual <int>(15, commandLine.GetOptionValue <int>("Option", 15)); }
public void FindLoweredOption_WhenParsingCamelCasedOption() { // Arrange SUT commandLine = new SUT(_argValid); // Assert Assert.AreEqual <int>(123, commandLine.GetOptionValue <int>("option", 15)); }
public void ReturnDefaultValue_WhenTryingToGetOptionThatNotExists() { // Arrange SUT commandLine = new SUT(_argValid); // Assert Assert.AreEqual <int>(15, commandLine.GetOptionValue <int>("NotExists", 15)); }