Exemplo n.º 1
0
        [Trait(Traits.Style, Traits.Regression)] // Legacy Tests, replace when working on them.
        public void BasicTest_GenerateShortHelp()
        {
            var clas = new CommandArgumentSupport();
            var c2   = new SampleCommandLine_C2();

            string help = clas.GenerateShortHelp(c2, "Tests");

            b.Info.Log("Help: " + help);
            Assert.True(help.Contains("~~MatchShortDescrFilename~~"), "The help message does not contain the short string");
        }
Exemplo n.º 2
0
        [Trait(Traits.Style, Traits.Regression)] // Legacy Tests, replace when working on them.
        public void TestIntAndLogMaxValues()
        {
            CommandArgumentSupport clas = new CommandArgumentSupport();

            clas.ArgumentPostfix        = ":";
            clas.ArgumentPrefix         = "";
            clas.ArgumentPrefixOptional = true;

            SampleCommandLine_C2 argsClass = new SampleCommandLine_C2();

            string[] args = new string[] {
                "filename:this is the filename",
                "INTVALUE:2147483647",
                "LONGVALUE:9223372036854775807"
            };
            clas.ProcessArguments(argsClass, args);
            Assert.Equal(int.MaxValue, argsClass.NumberParam1);
            Assert.Equal(long.MaxValue, argsClass.NumberParam2);
        }
Exemplo n.º 3
0
        [Trait(Traits.Style, Traits.Regression)] // Legacy Tests, replace when working on them.
        public void BasicTest_DefaultArguments()
        {
            var c2 = new SampleCommandLine_C2();

            VerifySampleCommandLine2_InitialSate(c2);
            string[] args = new string[] { "filename.txt" };

            CommandArgumentSupport clas = new CommandArgumentSupport();

            clas.ArgumentPrefix  = "-";
            clas.ArgumentPostfix = "=";
            clas.ProcessArguments(c2, args);

            Assert.Equal("filename.txt", c2.Filename);

            args[0] = "-filename=filename.txt";
            c2      = new SampleCommandLine_C2();
            VerifySampleCommandLine2_InitialSate(c2);
            clas.ProcessArguments(c2, args);

            Assert.Equal("filename.txt", c2.Filename);
        }
Exemplo n.º 4
0
        [Trait(Traits.Style, Traits.Regression)] // Legacy Tests, replace when working on them.
        public void IntegerParameter_TooLarge_ReturnsCorrectError()
        {
            var clas = new CommandArgumentSupport();

            clas.ArgumentPostfix        = ":";
            clas.ArgumentPrefix         = "";
            clas.ArgumentPrefixOptional = true;

            var argsClass = new SampleCommandLine_C2();

            string[] args = new string[] {
                "filename:this is the filename",
                "INTVALUE:2200000000",
            };
            clas.ProcessArguments(argsClass, args);

            string[] erroredArguments = clas.ListArgumentsWithErrors();

            Assert.True(erroredArguments.Length > 0, "there was an errored argument");
            Assert.True(erroredArguments[0].Contains("INTVALUE"), "The correct argument was not found");
            Assert.True(erroredArguments[0].Contains("too large"), "The incorrect reason was found");
        }
Exemplo n.º 5
0
 private static void VerifySampleCommandLine2_InitialSate(SampleCommandLine_C2 sc)
 {
     Assert.True(sc.Filename == null, "The filename for SC2 is not null, when it should be");
 }