public MessageHandlerMethodDispatcher(MethodInfo methodInfo, Type handledMessageType)
 {
     _executor = GetExecutor(methodInfo);
     MethodInfo = methodInfo;
     ParameterTypes = methodInfo.GetParameters().Select(x => x.ParameterType).ToList().AsReadOnly();
     HandledMessageType = handledMessageType;
 }
        public void Can_execute_cmd_without_bat_or_exe()
        {
            // setup
            var properties = new Dictionary<string, string>();
            properties["rootDirectory"] = _testDirectory.FullName;
            var execute = new ActionExecutor(new ConsoleWriter(), new RunContext { Properties = properties });
            File.WriteAllText(Path.Combine(_testDirectory.FullName, "test.txt"), "test");
            Directory.CreateDirectory(Path.Combine(_testDirectory.FullName, "test"));

            // act
            execute.Execute(new Command { Value = "xcopy /f/i \"$(rootDirectory)/test.txt\" \"$(rootDirectory)/test/\"" });

            // assert
            File.Exists(Path.Combine(_testDirectory.FullName, "test/test.txt"));
        }
        public void Can_execute_bat_without_cmd()
        {
            // setup
            var properties = new Dictionary<string, string>();
            properties["rootDirectory"] = _testDirectory.FullName;
            var writer = new Mock<IConsoleWriter>();
            writer.Setup(x => x.WriteError(It.IsAny<string>()));
            writer.Setup(x => x.WriteMessage(It.IsAny<string>()));
            var execute = new ActionExecutor(writer.Object, new RunContext { Properties = properties });
            var srcFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestData/test.bat");

            // act
            execute.Execute(new Command { Value = srcFile, dontUseCommandExe = true });

            // assert
            writer.Verify(x => x.WriteMessage("\"test property " + _testDirectory.FullName + "\""));
        }
 public ActionMethodDispatcher(MethodInfo methodInfo)
 {
     _executor = GetExecutor(methodInfo);
     MethodInfo = methodInfo;
 }
        public void When_invoking_power_shell_script_through_workflow_should_create_folders_as_directed_by_script()
        {
            // setup
            var properties = new Dictionary<string, string>();
            properties["rootDirectory"] = _testDirectory.FullName;
            var executor = new ActionExecutor(new ConsoleWriter(), new RunContext { Properties = properties });
            var srcFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestData/PSTestCreateFolders.ps1");

            // act
            executor.Execute(new PowerShell { Value = srcFile });

            // assert
            Assert.IsTrue(Directory.Exists(Path.Combine(_testDirectory.FullName, "TestFolder")), "TestFolder Creation Failed");
            Assert.IsTrue(Directory.Exists(Path.Combine(_testDirectory.FullName, "TestFolder\\TestFolder2")), "TestFolder\\TestFolder2 Creation Failed");
        }
        public void When_invoking_power_shell_with_errors_exception_is_thrown()
        {
            // setup
            var executor = new ActionExecutor(new ConsoleWriter(), new RunContext());
            var srcFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestData/PSTestError.ps1");

            // act
            try
            {
                executor.Execute(new PowerShell { Value = srcFile });
            }
            catch
            {
                return;
            }
            Assert.Fail("An error wasn't thrown");
        }
 public ActionMethodDispatcher(MethodInfo methodInfo)
 {
     _executor = GetExecutor(methodInfo);
     MethodInfo = methodInfo;
     ParameterTypes = methodInfo.GetParameters().Select(x => x.ParameterType).ToList().AsReadOnly();
 }
示例#8
0
 public static Action excuteAction(IEnumerator enumerator)
 {
     ActionExecutor actionExecutor = new ActionExecutor(enumerator);
     Instance.executorList.Add (actionExecutor);
     return actionExecutor;
 }
示例#9
0
        public bool run()
        {
            bool flag;
            if (aborted) return false;
            object current = this.enumerator.Current;
            if(current is Action)
            {
                if((current as Action).isDone())
                {
                    flag = this.enumerator.MoveNext();
                }
                else
                {
                    return true;
                }
            }
            else if(current is IEnumerator)
            {
                this.parent = new ActionExecutor(this.enumerator, this.parent);
                this.enumerator = current as IEnumerator;
                return this.run();

            }
               else
            {

                flag = this.enumerator.MoveNext();
            }
            if (!flag&&this.parent!=null)
            {
                this.enumerator = this.parent.enumerator;
                this.parent = this.parent.parent;
                return this.enumerator.MoveNext();
            }
            return flag;
        }
示例#10
0
 public ActionExecutor(IEnumerator enumerator,ActionExecutor parent=null)
 {
     this.enumerator = enumerator;
     this.parent = parent;
 }
 public MyReflectedActionDescriptor(ReflectedActionDescriptor actionDescriptor)
     : base(actionDescriptor.MethodInfo, actionDescriptor.ActionName, actionDescriptor.ControllerDescriptor)
 {
     this.ActionExecutor = new ActionExecutor(actionDescriptor.MethodInfo);
 }