public bool IsValid(CommandLineParameterWithValueCollection parameters)
        {
            ApplicationParameters param = new ApplicationParameters(parameters);

            return(param.GetSearchString().Count == param.GetReplaceString().Count);
            //return parameters.Exists(p => String.Compare(p.GetName(), "L", true) == 0);
            //{

            //}
        }
示例#2
0
 public void CheckParameters(CommandLineParameterWithValueCollection parameters)
 {
     foreach (IApplicationParameterValidator validator in this)
     {
         if (!validator.IsValid(parameters))
         {
             throw new InvalidArgumentOptionException(validator.GetValidationMessage());
         }
     }
 }
 public bool IsValid(CommandLineParameterWithValueCollection parameters)
 {
     if (parameters.Exists(p => String.Compare("P", p.GetName(), true) == 0))
     {
         string          paramFile = parameters.GetStringValue("P");
         FileParamReader reader    = new FileParamReader(paramFile);
         return(reader.GetAllSearchStrings().Count == File.ReadAllLines(paramFile).Length);
     }
     return(true);
 }
示例#4
0
        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());
        }
示例#5
0
        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 bool IsValid(CommandLineParameterWithValueCollection parameters)
 {
     foreach (CommandLineParameter mandatoryParam in _MandatoryParameters)
     {
         CommandLineParameterWithValue suppliedParam = parameters.Find(q => String.Compare(q.GetName(), mandatoryParam.GetName(), true) == 0);
         if (suppliedParam == null)
         {
             return(false);
         }
         if (String.IsNullOrEmpty(suppliedParam.GetValue()))
         {
             return(false);
         }
     }
     return(true);
 }
        public bool IsValid(CommandLineParameterWithValueCollection parameters)
        {
            ApplicationParameters param = new ApplicationParameters(parameters);

            if (param.GetLocationOptions().IsSet(SearchReplaceLocationOptions.ReplaceAttributeName) || param.GetLocationOptions().IsSet(SearchReplaceLocationOptions.ReplaceElementName))
            {
                foreach (string str in param.GetReplaceString())
                {
                    if (!Utility.IsValidXmlName(str))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
示例#8
0
        public void GetReplaceString_WithPParam_ReturnListOfReplaceStringsFromFileSpecified()
        {
            string paramFile = TestHelper.CreateParameterFile(new string[] { @"/S=""Book"" /R=""SmallBook""", @"/S=""Library"" /R=""Oxford""" });



            CommandLineParameterWithValueCollection values = new CommandLineParameterWithValueCollection();

            values.Add(new CommandLineParameterWithValue(new CommandLineParameter("P", String.Empty, String.Empty, false), paramFile));

            ApplicationParameters appParams = new ApplicationParameters(values);

            Assert.AreEqual(2, appParams.GetReplaceString().Count);
            Assert.AreEqual("SmallBook", appParams.GetReplaceString()[0]);
            Assert.AreEqual("Oxford", appParams.GetReplaceString()[1]);

            TestHelper.DeleteLastParameterFile();
        }
示例#9
0
 public bool IsValid(CommandLineParameterWithValueCollection parameters)
 {
     return(parameters.FindAll(p => !_SupportedParameters.Exists(q => String.Compare(q.GetName(), p.GetName(), true) == 0)).Count == 0);
 }
示例#10
0
 public bool IsValid(CommandLineParameterWithValueCollection parameters)
 {
     return(parameters.Exists(p => String.Compare("P", p.GetName(), true) == 0) ||
            parameters.Exists(p => String.Compare("S", p.GetName(), true) == 0));
 }