Esempio n. 1
0
        public XWorkstation(Initializer initializer,
                            CommandRegister commands,
                            FileSystem fileSystem)
            : base(initializer)
        {
            _scripts    = new List <object>();
            _fileSystem = fileSystem;
            var envVars = new HashSet <EnvVar>();

            if (initializer.Reader.WithOptionalChild("ApplySettings", out XElementReader rSettings))
            {
                foreach (var r in rSettings.WithChildren())
                {
                    if (r.Element.Name == "Script")
                    {
                        r.Handle(r.Element);
                        HandleScriptElement(r);
                    }
                    else if (r.Element.Name == "EnvironmentVariables")
                    {
                        r.Handle(r.Element);
                        envVars = r.HandleAddRemoveClearChildren(new HashSet <EnvVar>(envVars), rE => new EnvVar(rE, valueRequired: rE.Element.Name == "add"));
                        _scripts.Add(envVars);
                    }
                }
            }
            commands.Register(this);
        }
Esempio n. 2
0
        public void TestCommandRegister0()
        {
            ICallTester callTester = Substitute.For <ICallTester>();

            Command command = new Command();
            CommandRegister <ICallTester> cr = new CommandRegister <ICallTester>(command, caller => caller.Function1());

            cr.Register(0, callTester);
            command.Run("0Function1", new string[0]);
            callTester.Received(1).Function1();
            cr.Unregister(0);
        }
Esempio n. 3
0
        public void TestCommandRegister1()
        {
            // data
            Command command = new Command();
            CommandRegister <ICallTester, int> cr = new CommandRegister <ICallTester, int>(

                command,
                (caller, arg1) => caller.Function2(arg1));
            ICallTester callTester = Substitute.For <ICallTester>();

            // test
            cr.Register(0, callTester);
            command.Run(
                "0Function2",
                new[]
            {
                "1"
            });

            // verify
            cr.Unregister(0);
        }
Esempio n. 4
0
        public void TestCommandRegister1()
        {
            // data
            var command = new Command();
            var cr = new CommandRegister<ICallTester, int>(

                command,
                (caller, arg1) => caller.Function2(arg1));
            var callTester = Substitute.For<ICallTester>();

            // test
            cr.Register(callTester);
            command.Run(
                "Function2",
                new[]
                {
                    "1"
                });

            // verify
            cr.Unregister();
        }
Esempio n. 5
0
        public void TestCommandRegister0()
        {
            var callTester = Substitute.For<ICallTester>();

            var command = new Command();
            var cr = new CommandRegister<ICallTester>(command, caller => caller.Function1());

            cr.Register(callTester);
            command.Run("Function1", new string[0]);
            callTester.Received(1).Function1();
            cr.Unregister();
        }