public void FindLoweredOption_WhenParsingCamelCasedOption() { // Arrange SUT commandLine = new SUT(_argValid); // Assert Assert.AreEqual <int>(123, commandLine.GetOptionValue <int>("option", 15)); }
public void HaveOptionCountEqualToThree_WhenCallingWithThreeUnprefixArgumentsArray() { // Arrange SUT commandLine = new SUT(_argWithoutPrefix); // Assert Assert.IsTrue(commandLine.OptionCount == 3); }
public void ReturnTheDefaultValue_WhenCallingWithAnArgumentWithoutValue() { // Arrange SUT commandLine = new SUT(_argWithoutValue); // Assert Assert.AreEqual <int>(15, commandLine.GetOptionValue <int>("Option", 15)); }
public void HaveOptionCountEqualToZero_WhenCallWithAnEmptyStringArray() { // Arrange SUT commandLine = new SUT(_argWithEmptyOptions); // Assert Assert.IsTrue(commandLine.OptionCount == 0); }
public void ReturnDefaultValue_WhenTryingToGetOptionThatNotExists() { // Arrange SUT commandLine = new SUT(_argValid); // Assert Assert.AreEqual <int>(15, commandLine.GetOptionValue <int>("NotExists", 15)); }
public void ThrowAnException_WhenParsingArgumentWithoutName() { // Arrange SUT commandLine = new SUT(_argWithoutName); // Assert Assert.Fail(); }
public void HaveOptionCountEqualToThree_WhenCallingWithThreeAlternativePrefixArgumentsArray() { // Arrange SUT commandLine = new SUT(_argWithAsterikAsPrefix); commandLine.Prefix += "*"; // Assert Assert.IsTrue(commandLine.OptionCount == 3); }
public void ReturnTrue_WhenCallingOptionExistsForAnOptionThatExists() { // Arrange SUT commandLine = new SUT(_argValid); // Assert Assert.IsTrue(commandLine.OptionExists("Server")); Assert.IsTrue(commandLine.OptionExists("ssl")); Assert.IsTrue(commandLine.OptionExists("opTION")); }
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); } }