Exemple #1
0
        public void ArgumentExecuter_CanExecuteMethodWithInput()
        {
            var executer = new ArgumentExecutor();
            var result   = executer.Execute <TestClass_Input>("99.9");

            Assert.IsNotNull(result);
            Assert.AreEqual(99.9, result.SomeInput);
        }
Exemple #2
0
        public void ArgumentExecuter_CanExecuteMethodsWithInput()
        {
            var executer = new ArgumentExecutor();
            var result   = executer.Execute <TestClass_MethodsWithParameters>("--v:5");

            Assert.IsNotNull(result);
            Assert.AreEqual(50, result.Value);
        }
Exemple #3
0
        public void ArgumentExecuter_CanExecuteMethodWithInputAndOther()
        {
            var executer = new ArgumentExecutor();
            var result   = executer.Execute <TestClass_InputWithAdditionalOptions>("99.9", "-h");

            Assert.IsNotNull(result);
            Assert.AreEqual(99.9, result.SomeInput);
            Assert.IsTrue(result.HelpExecuted);
        }
Exemple #4
0
        public void ArgumentExecuter_CanExecuteParameterlessMethods()
        {
            var executer = new ArgumentExecutor();
            var result   = executer.Execute <TestClass_ParameterlessMethods>("MyMethod1", "--someOtherMethod");

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Method1Executed);
            Assert.IsTrue(result.Method2Executed);

            var targetInstance = new TestClass_ParameterlessMethods();

            executer.Execute(targetInstance, "MyMethod1", "--someOtherMethod");
            Assert.IsTrue(targetInstance.Method1Executed);
            Assert.IsTrue(targetInstance.Method2Executed);
        }
Exemple #5
0
        public void ArgumentExecuter_CanExecuteMethodWithOutputAndOther()
        {
            var executer = new ArgumentExecutor();
            var result   = executer.Execute <TestClass_OutputWithAdditionalOptions>("-h", "55");

            Assert.IsNotNull(result);
            Assert.AreEqual(55, result.SomeOutput);
            Assert.IsTrue(result.HelpExecuted);

            var targetInstance = new TestClass_OutputWithAdditionalOptions();

            executer.Execute(targetInstance, "-h", "55");
            Assert.AreEqual(55, targetInstance.SomeOutput);
            Assert.IsTrue(targetInstance.HelpExecuted);
        }
Exemple #6
0
        static void Main(string[] args)
        {
            var parser        = new AttributeParser();
            var configuration = parser.Parse <ProgramConfig>(args);

            if (configuration.ShowHelp)
            {
                Console.WriteLine("HEEELP");
            }



            var c        = new ConfigExec();
            var executor = new ArgumentExecutor();

            executor.Execute(c, args);

            Console.ReadLine();
        }
Exemple #7
0
        public void ArgumentExecuter_CanExecuteMethodsWithInputAndConverter()
        {
            var executer = new ArgumentExecutor();

            executer.RegisterCustomConverter <MyCustomType>(x =>
            {
                if (x == "magicValue")
                {
                    return(new MyCustomType {
                        Id = "Works!"
                    });
                }
                return(null);
            });
            var result = executer.Execute <TestClass_MethodsWithParameterAndCustomConversionNeeded>("--v=magicValue");

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Value);
            Assert.AreEqual("Works!", result.Value.Id);
        }