public void ParameterParseTest_ParseString()
    {
      string[] args;
      ParameterComplex parameter = new ParameterComplex("ParameterParseTest", Assembly.GetExecutingAssembly());

      parameter.Parse(argsNull);
      Assert.AreEqual(ParseResultEnum.NOT_PARSED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "String").Single().ParseResult);

      args = new string[] {"String=\"\t  \""};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_FAILED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "String").Single().ParseResult);

      args = new string[] {"String=\"\r\n\""};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_FAILED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "String").Single().ParseResult);

      args = new string[] {"String=\"String parse\""};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_SUCCEEDED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "String").Single().ParseResult);

      args = new string[] {"String=a b c d"};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_SUCCEEDED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "String").Single().ParseResult);

      args = new string[] {"String=\"User Id=User;Password=P@ssword;POOLING=True;MIN POOL SIZE=1;MAX POOL SIZE=100;Incr Pool Size=5;DECR POOL SIZE=1;CONNECTION LIFETIME=60;VALIDATE CONNECTION=True;Data Source=ABCDEFG.RZ\""};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_SUCCEEDED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "String").Single().ParseResult);

      args = new string[] {"String=\"Server=ABCDEFG,1435;Database=Test;Trusted_Connection=yes;\""};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_SUCCEEDED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "String").Single().ParseResult);
    }
        public void ParameterComplex_ValidationFailMandatoryTest()
        {
            ParameterComplex parameterComplex = new ParameterComplex("ParameterComplexTest", Assembly.GetExecutingAssembly());

            string[] args = new String[] { "MNullBoolParam=true" };

            parameterComplex.Parse(args);

            //
            // Mandatory parameter
            //
            Assert.AreEqual(null, parameterComplex.MStringParam, "The parameter property 'MStringParam' value should be null.");
            Assert.AreEqual(null, parameterComplex.MNullInt32Param, "The parameter property 'MNullInt32Param' should be null.");
            //Assert.AreEqual(true, parameterComplex.MNullBoolParam, "The parameter property 'MNullBoolParam' value should be null.");

            var IsValid = parameterComplex.Validate();

            Assert.IsFalse(IsValid, "The validation for object 'parameterComplex' should fail because of the missing mandatory arguments.");
            Assert.AreEqual(2, parameterComplex.ValidationErrorList.Count(), "There should be 2 validation errors.");

            var MStringParamErr    = parameterComplex.ValidationErrorList.Where(err => err.PropertyMetaInfo.Name == "MStringParam").FirstOrDefault();
            var MNullInt32ParamErr = parameterComplex.ValidationErrorList.Where(err => err.PropertyMetaInfo.Name == "MNullInt32Param").FirstOrDefault();

            //varMNullBoolParamErr = parameterComplex.ValidationErrorList.Where(err => err.PropertyMetaInfo.Name == "MNullBoolParam").FirstOrDefault();

            Assert.IsNotNull(MStringParamErr, "There should be an error object for the mandatory 'MStringParam' property which wasn't set.");
            Assert.IsNotNull(MNullInt32ParamErr, "There should be an error object for the mandatory 'MNullInt32Param' property which wasn't set.");
        }
    public void ParameterParseTest_ParseNullChar()
    {
      string[] args;
      ParameterComplex parameter = new ParameterComplex("ParameterParseTest" , Assembly.GetExecutingAssembly());

      parameter.Parse(argsNull);
      Assert.AreEqual(ParseResultEnum.NOT_PARSED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullChar").Single().ParseResult);

      args = new string[] {"NullChar="};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_FAILED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullChar").Single().ParseResult);

      args = new string[] {"NullChar=abcd"};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_FAILED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullChar").Single().ParseResult);

      args = new string[] {"NullChar=' '"};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_SUCCEEDED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullChar").Single().ParseResult);

      args = new string[] {"NullChar='@'"};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_SUCCEEDED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullChar").Single().ParseResult);

      args = new string[] {"NullChar=X"};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_SUCCEEDED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullChar").Single().ParseResult);

      args = new string[] {"NullChar=null"};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_SUCCEEDED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullChar").Single().ParseResult);

    }
        public void ParameterComplex_HelpTest()
        {
            ParameterComplex parameterComplex = new ParameterComplex("ParameterComplexTest", Assembly.GetExecutingAssembly());
            string           helpStr          = parameterComplex.CreateHelp();

            Assert.IsNotNull(helpStr);

            Debugger.Log(1, "HelpTest", helpStr);
        }
        public void ParameterComplex_ValidationFailTest()
        {
            ParameterComplex parameterComplex = new ParameterComplex("ParameterComplexTest", Assembly.GetExecutingAssembly());

            string[] args = new String[] { "String=\"C://TEMP\"", "Single=1.5", "Double=2.5", "Decimal=25.123", "Int16=16",
                                           "Int32=32", "Int64=64", "Bool=true",
                                           "Internal=\"Internal parsed value.\"", "Foo=123", "Bar=test",
                                           "MNullBoolParam=true" };
            parameterComplex.Parse(args);

            Assert.AreEqual("C://TEMP", parameterComplex.StringParam, "The parameter property 'StringParam' value should match with the parsed argument value.");
            Assert.AreEqual(1.5, parameterComplex.SingleParam, "The parameter property 'SingleParam' value should match with the  parsed argument value.");
            Assert.AreEqual(2.5, parameterComplex.DoubleParam, "The parameter property 'DoubleParam' value should match with the  parsed argument value.");
            Assert.AreEqual(25.123m, parameterComplex.DecimalParam, "The parameter property 'DecimalParam' value should match with the  parsed argument value.");
            Assert.AreEqual(16, parameterComplex.Int16Param, "The parameter property 'Int16Param' value should match with the parsed argument value.");
            Assert.AreEqual(32, parameterComplex.Int32Param, "The parameter property 'Int32Param' value should match with the parsed argument value.");
            Assert.AreEqual(64, parameterComplex.Int64Param, "The parameter property 'Int64Param' value should match with the parsed argument value.");
            Assert.AreEqual(true, parameterComplex.BoolParam, "The parameter property 'BoolParam' value should match with the parsed argument value.");

            //
            // Excluded parameter
            //
            Assert.AreNotEqual("Internal parsed value.", parameterComplex.InternalParam, "The parameter property 'InternalParam' value should not match with the parsed argument value.");
            //Assert.AreNotEqual("123", parameterComplex.FooParam, "The parameter 'FooParam' property value should not match with the parsed argument value.");
            Assert.AreNotEqual("test", parameterComplex.BarParam, "The parameter property 'BarParam' should not match with the parsed argument value.");

            //
            // Mandatory parameter
            //
            Assert.AreEqual(null, parameterComplex.MStringParam, "The parameter property 'MStringParam' value should be null.");
            Assert.AreEqual(null, parameterComplex.MNullInt32Param, "The parameter property 'MNullInt32Param' should be null.");
            //Assert.AreEqual(true, parameterComplex.MNullBoolParam, "The parameter property 'MNullBoolParam' value should be null.");

            var IsValid = parameterComplex.Validate();

            Assert.IsFalse(IsValid, "The validation for object 'parameterComplex' should fail because of the missing mandatory arguments.");
            Assert.AreEqual(2, parameterComplex.ValidationErrorList.Count(), "There should be 2 validation errors.");

            var MStringParamErr    = parameterComplex.ValidationErrorList.Where(err => err.PropertyMetaInfo.Name == "MStringParam").FirstOrDefault();
            var MNullInt32ParamErr = parameterComplex.ValidationErrorList.Where(err => err.PropertyMetaInfo.Name == "MNullInt32Param").FirstOrDefault();

            //varMNullBoolParamErr = parameterComplex.ValidationErrorList.Where(err => err.PropertyMetaInfo.Name == "MNullBoolParam").FirstOrDefault();

            Assert.IsNotNull(MStringParamErr, "There should be an error object for the mandatory 'MString' property which wasn't set.");
            Assert.IsNotNull(MNullInt32ParamErr, "There should be an error object for the mandatory 'MInt32Err' property which wasn't set.");
        }
        public void ParameterComplex_ValidationFailInvalidArgumentTest()
        {
            ParameterComplex parameterComplex = new ParameterComplex("ParameterComplexTest", Assembly.GetExecutingAssembly());

            string[] args = new String[] { "String=\"C://TEMP\"", "Single=not a number" };

            parameterComplex.Parse(args);

            Assert.AreEqual(ParseResultEnum.PARSE_SUCCEEDED, parameterComplex.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "String").Single().ParseResult, "The meta info parse result of parameter property 'StringParam' should be 'PARSE_SUCCEEDED'.");
            Assert.AreEqual(ParseResultEnum.PARSE_FAILED, parameterComplex.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "Single").Single().ParseResult, "The meta info of parameter property 'SingleParm' should be 'PARSE_FAILED'.");

            var IsValid = parameterComplex.Validate();

            Assert.IsFalse(IsValid, "The validation for object 'parameterComplex' should fail because of the invalid argument value and the missing mandatory arguments.");
            Assert.AreEqual(4, parameterComplex.ValidationErrorList.Count(), "There should be 4 validation errors.");

            var SingleParamErr = parameterComplex.ValidationErrorList.Where(err => err.PropertyMetaInfo.Name == "Single").FirstOrDefault();

            Assert.IsNotNull(SingleParamErr, "There should be an error object for the 'SingleParam' property which was assigned an invalid value.");
        }
    public void ParameterParseTest_ParseNullBool()
    {
      string[] args;
      ParameterComplex parameter = new ParameterComplex("ParameterParseTest", Assembly.GetExecutingAssembly());

      parameter.Parse(argsNull);
      Assert.AreEqual(ParseResultEnum.NOT_PARSED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullBool").Single().ParseResult);

      args = new string[] {"NullBool="};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_FAILED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullBool").Single().ParseResult);

      args = new string[] {"NullBool=0.123456"};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_FAILED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullBool").Single().ParseResult);

      args = new string[] {"NullBool=true"};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_SUCCEEDED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullBool").Single().ParseResult);

      args = new string[] {"NullBool=Yes"};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_SUCCEEDED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullBool").Single().ParseResult);

      args = new string[] {"NullBool=False"};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_SUCCEEDED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullBool").Single().ParseResult);

      args = new string[] {"NullBool=no"};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_SUCCEEDED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullBool").Single().ParseResult);

      args = new string[] {"NullBool=Null"};
      parameter.Parse(args);
      Assert.AreEqual(ParseResultEnum.PARSE_SUCCEEDED, parameter.PropertyMetaInfoList.Where(propInfo => propInfo.Name == "NullBool").Single().ParseResult);
    }
        public void ParameterComplex_ConstructorTest()
        {
            ParameterComplex parameterComplex = new ParameterComplex("ParameterComplexTest", Assembly.GetExecutingAssembly());

            Assert.IsNotNull(parameterComplex, "The 'ParameterComplex' constructor should return a valid instance.");
        }