public void GetUsageTest() { string expectedUsage = "tt.exe " + CommandLineParameterCollection.GetUsage() + Environment.NewLine; expectedUsage += CommandLineParameterCollection.GetHelpText(); Assert.AreEqual(expectedUsage, SearchReplaceFileReplacer.GetUsage("tt.exe")); }
private void SetupAndAssert(bool expectedResult, string commandLine, params string[] mandatoryParams) { CommandLineParameterCollection mandatoryList = new CommandLineParameterCollection(); foreach (string s in mandatoryParams) { mandatoryList.Add(new CommandLineParameter(s)); } EnsureAllMandatoryParametersArePresentValidator validator = new EnsureAllMandatoryParametersArePresentValidator(mandatoryList); Assert.AreEqual(expectedResult, validator.IsValid(TestHelper.GetCommandLineParameters(commandLine))); }
private void SetupAndAssert(bool expectedResult, string commandLine, params string[] supportedParams) { CommandLineParameterCollection supportedParamsColl = new CommandLineParameterCollection(); foreach (string s in supportedParams) { supportedParamsColl.Add(new CommandLineParameter(s)); } EnsureSupportedParametersOnlyValidator validator = new EnsureSupportedParametersOnlyValidator(supportedParamsColl, String.Empty); Assert.AreEqual(expectedResult, validator.IsValid(TestHelper.GetCommandLineParameters(commandLine))); }
public void CheckMissingParamsAreDetected() { CommandLineParameterCollection mandatoryParams = new CommandLineParameterCollection(); mandatoryParams.Add(new CommandLineParameter("A", String.Empty, String.Empty, true)); mandatoryParams.Add(new CommandLineParameter("B", String.Empty, String.Empty, false)); CommandLineParameterWithValueCollection values = new CommandLineParameterWithValueCollection(); values.Add(new CommandLineParameterWithValue(mandatoryParams[1], String.Empty)); Assert.AreEqual(1, ApplicationParameterValidator.GetMissingMandatoryParams(mandatoryParams, values).Count); Assert.AreEqual("A", ApplicationParameterValidator.GetMissingMandatoryParams(mandatoryParams, values)[0].GetName()); }
public void GetReplaceString_WithLParam_WillReturnSearchStringInLowerCase() { CommandLineParameterCollection mandatoryParams = new CommandLineParameterCollection(); mandatoryParams.Add(new CommandLineParameter("S", String.Empty, String.Empty, true)); CommandLineParameterWithValueCollection param = new CommandLineParameterWithValueCollection(); param.Add(new CommandLineParameterWithValue(mandatoryParams[0], "HelloWorld")); param.Add(new CommandLineParameterWithValue(new CommandLineParameter("L", String.Empty, String.Empty, false), string.Empty)); ApplicationParameters values = new ApplicationParameters(param); Assert.AreEqual("HelloWorld", values.GetSearchString()[0]); Assert.AreEqual("helloworld", values.GetReplaceString()[0]); }
public void GetHelpText_WillReturnHelpText() { string expectedHelpText = "S - " + HelpText.SearchString + " (optional)" + Environment.NewLine; expectedHelpText += "R - " + HelpText.ReplaceString + " (optional)" + Environment.NewLine; expectedHelpText += "O - " + HelpText.Option + Environment.NewLine; expectedHelpText += "F - " + HelpText.FileName + Environment.NewLine; expectedHelpText += "C - " + HelpText.ContinueOnError + " (optional)" + Environment.NewLine; expectedHelpText += "I - " + HelpText.IgnoreCase + " (optional)" + Environment.NewLine; expectedHelpText += "W - " + HelpText.WholeWordOnly + " (optional)" + Environment.NewLine; expectedHelpText += "D - " + HelpText.RecurseSubDir + " (optional)" + Environment.NewLine; expectedHelpText += "L - " + HelpText.ReplaceSearchStringByLowerCase + " (optional)" + Environment.NewLine; expectedHelpText += "P - " + HelpText.ParameterFile + " (optional)" + Environment.NewLine; expectedHelpText += HelpText.MoreInfo; Assert.AreEqual(expectedHelpText, CommandLineParameterCollection.GetHelpText()); }
public static CommandLineParameterWithValueCollection GetCommandLineParameters(string commandLine, CommandLineParameterCollection supportedParams) { CommandlineParser parser = new CommandlineParser(commandLine); return(parser.GetParamsAndValues()); }
public EnsureSupportedParametersOnlyValidator(CommandLineParameterCollection supportedParameters, string message) { this._SupportedParameters = supportedParameters; _Message = message; }
public void GetUsage_WillReturnValidUsage() { string expectedCommandLine = @"[/S]=""search"" [/R]=""replace"" /O=en,ev,an,av,va,ve /F=""C:\Files\*.xml"" [/C] [/I] [/W] [/D] [/L] [/P]=""C:\Files\params.txt"""; Assert.AreEqual(expectedCommandLine, CommandLineParameterCollection.GetUsage()); }
public EnsureAllMandatoryParametersArePresentValidator(CommandLineParameterCollection mandatoryParameters) { _MandatoryParameters = mandatoryParameters; }