예제 #1
0
        [Trait(Traits.Style, Traits.Regression)] // Legacy Tests, replace when working on them.
        public void BasicTest_NumberStringAndBoolParams()
        {
            b.Info.Log("Starting test for SimpleArguments");

            const string STRINGPAR1 = "StringParameter1";
            const string STRINGPAR2 = "StrnigParameter2";
            const int    NUMVALUE   = 12;
            var          sc1        = new SampleCommandLine_C1();

            VerifySampleCommandLine1_InitialState(sc1);

            string[] args = new string[] { "/N:" + STRINGPAR1, "/A:" + STRINGPAR2, "/C:" + NUMVALUE.ToString(), "/OP1" };

            var clas = new CommandArgumentSupport();

            clas.ArgumentPrefix = "/";

            clas.ProcessArguments(sc1, args);

            Assert.Equal(STRINGPAR1, sc1.NameParameterOne);
            Assert.Equal(STRINGPAR2, sc1.NameParameterTwo);

            Assert.True(sc1.OptionParameterOne, "Boolean parameter one failed");
            Assert.False(sc1.OptionParameterTwo, "Boolean argument two failed");

            Assert.Equal(12, sc1.NumberParameterOne);
            Assert.Equal(0, sc1.NumberParameterTwo);
        }
예제 #2
0
        /// <summary>
        /// Used so that when we change the definition of SampleCommandLine_C1 we dont break all of the unit tests in a strange way.
        /// </summary>
        /// <param name="sc">A SampleCommandLine_C1 class</param>
        private static void VerifySampleCommandLine_InitialState(SampleCommandLine_C1 sc)
        {
            Assert.Equal(string.Empty, sc.NameParameterOne);
            Assert.Equal(string.Empty, sc.NameParameterTwo);

            Assert.False(sc.OptionParameterOne, "Boolean parameter one invalid start state");
            Assert.False(sc.OptionParameterTwo, "Boolean argument two invalid start state");

            Assert.Equal(0, sc.NumberParameterOne);
            Assert.Equal(0, sc.NumberParameterTwo);
        }
예제 #3
0
        [Trait(Traits.Style, Traits.Regression)] // Legacy Tests, replace when working on them.
        public void BasicTest_BooleanParameters()
        {
            b.Info.Log("Starting  Testing boolean behaviour");

            var sc1 = new SampleCommandLine_C1();
            var sc2 = new SampleCommandLine_C1();
            var sc3 = new SampleCommandLine_C1();

            VerifySampleCommandLine1_InitialState(sc1);
            VerifySampleCommandLine1_InitialState(sc2);
            VerifySampleCommandLine1_InitialState(sc3);

            string[] argsBothTrue  = new string[] { "/OP1", "/OP2" };
            string[] argsBothTrue2 = new string[] { "/OP1true", "/OP2TRUE" };
            string[] argsBothTrue3 = new string[] { "/OP1YES", "/OP2y" };

            CommandArgumentSupport clas = new CommandArgumentSupport();

            clas.ArgumentPrefix = "/";
            clas.ProcessArguments(sc1, argsBothTrue);

            Assert.True(sc1.OptionParameterOne);
            Assert.True(sc1.OptionParameterTwo);

            clas.ProcessArguments(sc2, argsBothTrue2);
            clas.ProcessArguments(sc3, argsBothTrue3);

            Assert.Equal(sc1.OptionParameterOne, sc2.OptionParameterOne);
            Assert.Equal(sc1.OptionParameterTwo, sc2.OptionParameterTwo);
            Assert.Equal(sc1.OptionParameterOne, sc3.OptionParameterOne);
            Assert.Equal(sc1.OptionParameterTwo, sc3.OptionParameterTwo);

            string[] argsBothFalse  = new string[] { "/OP1false", "/OP2no" };
            string[] argsBothFalse2 = new string[] { "/OP1N", "/OP2False" };

            sc1.OptionParameterOne = true;
            sc1.OptionParameterTwo = true;
            clas.ProcessArguments(sc1, argsBothFalse);

            Assert.False(sc1.OptionParameterOne);
            Assert.False(sc1.OptionParameterTwo);

            sc1.OptionParameterOne = true;
            sc1.OptionParameterTwo = true;
            clas.ProcessArguments(sc1, argsBothFalse2);

            Assert.False(sc1.OptionParameterOne);
            Assert.False(sc1.OptionParameterTwo);
        }
예제 #4
0
        [Trait(Traits.Style, Traits.Regression)] // Legacy Tests, replace when working on them.
        public void BasicTest_ArgumentPrefix()
        {
            b.Info.Log("Starting  Testing Argument prefix behaviour");

            SampleCommandLine_C1 sc1 = new SampleCommandLine_C1();

            VerifySampleCommandLine1_InitialState(sc1);

            // Should be identical with differing prefixes.
            string[] argsBothTrue  = new string[] { "-OP1", "-OP2" };
            string[] argsBothTrue2 = new string[] { "XOP1", "XOP2" };
            string[] argsBothTrue3 = new string[] { "OP1", "OP2" };

            CommandArgumentSupport clas = new CommandArgumentSupport();

            clas.ArgumentPrefix    = "-";
            sc1.OptionParameterOne = sc1.OptionParameterTwo = false;
            clas.ProcessArguments(sc1, argsBothTrue);

            Assert.True(sc1.OptionParameterOne);
            Assert.True(sc1.OptionParameterTwo);

            sc1.OptionParameterOne = sc1.OptionParameterTwo = false;
            clas.ArgumentPrefix    = "X";
            clas.ProcessArguments(sc1, argsBothTrue2);

            Assert.True(sc1.OptionParameterOne);
            Assert.True(sc1.OptionParameterTwo);

            sc1.OptionParameterOne = sc1.OptionParameterTwo = false;
            clas.ArgumentPrefix    = "";
            clas.ProcessArguments(sc1, argsBothTrue3);

            Assert.True(sc1.OptionParameterOne);
            Assert.True(sc1.OptionParameterTwo);

            b.Info.Log("TESTOK: Finished Testing ArgumentPrefix");
        }