public void SingleSwitchParameter()
        {
            var sig = new TypedSignature<SingleSwitchParameterSignature>(
                "test",
                "TestComand",
                (data, errors) => true);

            TypeSignatureAssert.LineRuns(true, sig, "test");
            TypeSignatureAssert.LineRuns(true, sig, "test -param1");
            TypeSignatureAssert.LineRuns(false, sig, $"test -param1:badValue");
        }
Beispiel #2
0
        public void SingleSwitchParameter()
        {
            var sig = new TypedSignature <SingleSwitchParameterSignature>(
                "test",
                "TestComand",
                (data, errors) => true);

            TypeSignatureAssert.LineRuns(true, sig, "test");
            TypeSignatureAssert.LineRuns(true, sig, "test -param1");
            TypeSignatureAssert.LineRuns(false, sig, $"test -param1:badValue");
        }
Beispiel #3
0
        public void SingleTokenParameter()
        {
            var sigName = new TypedSignature <SingleTokenParameterSignature>(
                "test",
                "TestComand",
                (data, errors) => true);

            TypeSignatureAssert.LineRuns(true, sigName, $"test param1");
            TypeSignatureAssert.LineRuns(false, sigName, $"test");
            TypeSignatureAssert.LineRuns(false, sigName, $"test badValue");
        }
Beispiel #4
0
        public static bool TestLine <T>(TypedSignature <T> sig, string line) where T : class, new()
        {
            var ci  = CommandInput.Parse(line);
            var can = sig.CanRun(ci);
            var run = false;

            if (can)
            {
                run = sig.Run(ci, new List <CommandError>());
            }
            return(can && run);
        }
        public void SingleIndexParameter()
        {
            var value = "TestValueParam1";

            var sigNameIndex = new TypedSignature<SingleIndexParameterSignature>(
                "test",
                "TestComand",
                (data, errors) => data.Param1 == value);

            TypeSignatureAssert.LineRuns(true, sigNameIndex, $"test {value}");
            TypeSignatureAssert.LineRuns(true, sigNameIndex, $"test -param1:{value}");
            TypeSignatureAssert.LineRuns(false, sigNameIndex, $"test");
        }
Beispiel #6
0
        public void SingleIndexParameter()
        {
            var value = "TestValueParam1";

            var sigNameIndex = new TypedSignature <SingleIndexParameterSignature>(
                "test",
                "TestComand",
                (data, errors) => data.Param1 == value);

            TypeSignatureAssert.LineRuns(true, sigNameIndex, $"test {value}");
            TypeSignatureAssert.LineRuns(true, sigNameIndex, $"test -param1:{value}");
            TypeSignatureAssert.LineRuns(false, sigNameIndex, $"test");
        }
        public void SingleNamedParameter()
        {
            var value = "TestValueParam1";

            var sigName = new TypedSignature<SingleNameParameterSignature>(
                "test",
                "TestComand",
                (data, errors) => true);

            TypeSignatureAssert.LineRuns(true, sigName, $"test");
            TypeSignatureAssert.LineRuns(true, sigName, $"test -param1:{value}");
            // Can run as the param1 parameter is not mandatory, but should crash because of the unidentified parameters
            TypeSignatureAssert.LineRuns(false, sigName, $"test {value}");
        }
Beispiel #8
0
        public void SingleNamedParameter()
        {
            var value = "TestValueParam1";

            var sigName = new TypedSignature <SingleNameParameterSignature>(
                "test",
                "TestComand",
                (data, errors) => true);

            TypeSignatureAssert.LineRuns(true, sigName, $"test");
            TypeSignatureAssert.LineRuns(true, sigName, $"test -param1:{value}");
            // Can run as the param1 parameter is not mandatory, but should crash because of the unidentified parameters
            TypeSignatureAssert.LineRuns(false, sigName, $"test {value}");
        }
        public void AllParameters()
        {
            var value = "SomeValue";

            var sig = new TypedSignature<AllParametersSignature>(
                "test",
                "TestComand",
                (data, errors) => data.Param1 == "param1");

            TypeSignatureAssert.LineRuns(true, sig, "test param1");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 {value}");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 -param2:{value}");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 -param2:{value} -param3:{value}");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 -param3:{value} -param2:{value}");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 -param2:{value} -param3:{value} -param4");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 -param3:{value} -param4 -param2:{value}");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 -param4 -param2:{value} -param3:{value} ");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 -param2:{value} -param4");

            TypeSignatureAssert.LineRuns(false, sig, $"test -param2:{value} -param4");
            TypeSignatureAssert.LineRuns(false, sig, $"test -param4 param1 -param2:{value}");
        }
Beispiel #10
0
        public void AllParameters()
        {
            var value = "SomeValue";

            var sig = new TypedSignature <AllParametersSignature>(
                "test",
                "TestComand",
                (data, errors) => data.Param1 == "param1");

            TypeSignatureAssert.LineRuns(true, sig, "test param1");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 {value}");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 -param2:{value}");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 -param2:{value} -param3:{value}");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 -param3:{value} -param2:{value}");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 -param2:{value} -param3:{value} -param4");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 -param3:{value} -param4 -param2:{value}");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 -param4 -param2:{value} -param3:{value} ");
            TypeSignatureAssert.LineRuns(true, sig, $"test param1 -param2:{value} -param4");

            TypeSignatureAssert.LineRuns(false, sig, $"test -param2:{value} -param4");
            TypeSignatureAssert.LineRuns(false, sig, $"test -param4 param1 -param2:{value}");
        }
        public void SingleTokenParameter()
        {
            var sigName = new TypedSignature<SingleTokenParameterSignature>(
                "test",
                "TestComand",
                (data, errors) => true);

            TypeSignatureAssert.LineRuns(true, sigName, $"test param1");
            TypeSignatureAssert.LineRuns(false, sigName, $"test");
            TypeSignatureAssert.LineRuns(false, sigName, $"test badValue");
        }
        public static void LineRuns <T>(bool shouldRun, TypedSignature <T> sig, string line) where T : class, new()
        {
            var result = TypeSignatureTestHelpers.TestLine(sig, line);

            Assert.AreEqual(shouldRun, result);
        }