Ejemplo n.º 1
0
        public void Execute_calls_new_process()
        {
            string expectedTool = "Tool1";
            string inputArgs    = "Arg1 Arg2";
            string expectedArgs = "ABC DEF";

            var runctx = new RunContext()
            {
                Config = new RunConfig()
                {
                    RunTool = expectedTool,
                    RunArgs = inputArgs,
                },
                ConnectionString = new SqlConnectionStringBuilder()
                {
                    DataSource         = "127.0.0.1",
                    InitialCatalog     = "MYDATABASE",
                    UserID             = "user1",
                    Password           = "******",
                    IntegratedSecurity = false
                },
            };

            IRunContextProvider contextProvider = A.Fake <IRunContextProvider>();

            A.CallTo(() => contextProvider.Get()).Returns(runctx);

            IRunParamsProcessor paramsProcessor = A.Fake <IRunParamsProcessor>();

            A.CallTo(() => paramsProcessor.Compose(inputArgs, runctx.ConnectionString)).Returns(expectedArgs);

            IRunProcessStarter processStarter = A.Fake <IRunProcessStarter>();

            RunAction runAction = new RunAction(contextProvider, paramsProcessor, processStarter);

            runAction.Execute();

            A.CallTo(() => processStarter.Start(expectedTool, expectedArgs)).MustHaveHappenedOnceExactly();
        }
Ejemplo n.º 2
0
        public string Execute()
        {
            try
            {
                RunContext context = _contextProvider.Get();
                RunConfig  config  = context.Config;
                string     args    = _paramsProcessor.Compose(config.RunArgs, context.ConnectionString);
                _process.Start(config.RunTool, args);
            }
            catch (RunConfigUndefinedException)
            {
                return("Undefined");
            }
            catch (ConnectionInfoException)
            {
                return("Insufficient connection info");
            }
            catch (Exception)
            {
                throw;
            }

            return("Tool runned");
        }