public void KillMultipleInstruction()
        {
            var multiple = new Program.MultipleInstruction(new List <Program.Instruction> {
                new Program.CommandInstruction("cmd", new List <string> {
                    "1"
                }, this.commandLine),
                new Program.WaitInstruction("2"),
                new Program.CommandInstruction("cmd", new List <string> {
                    "2"
                }, this.commandLine)
            });

            multiple.Execute(this.process, this.mock.Action, new List <string>());

            this.tick();
            Assert.IsTrue(this.getProcesses().Any(s => s.Contains("ar-wait")));

            this.manager.KillAll("ar-wait");
            this.tick();

            Assert.AreEqual(1, this.getProcesses().Count);
            Assert.AreEqual(2, this.commandCalls.Count);
            Assert.AreEqual("1", this.commandCalls[0]);
            Assert.AreEqual("2", this.commandCalls[1]);
            Assert.IsTrue(this.mock.Called);
        }
        public void Placeholders()
        {
            var multipleInstruction = new Program.MultipleInstruction(
                new List <Program.Instruction> {
                new Program.CommandInstruction("cmd", new List <string> {
                    "$1"
                }, this.commandLine),
                new Program.CommandInstruction("cmd", new List <string> {
                    "$1", "$4"
                }, this.commandLine),
                new Program.WaitInstruction("$3"),
            }
                );

            multipleInstruction.Execute(this.process, this.mock.Action, new List <string> {
                "arg1", "arg2", "4", "arg4"
            });

            this.tick();

            Assert.IsFalse(this.mock.Called);
            Assert.AreEqual(1, this.commandCalls.Count);
            Assert.AreEqual("arg1", this.commandCalls[0]);

            this.tick();

            Assert.IsFalse(this.mock.Called);
            Assert.AreEqual(2, this.commandCalls.Count);
            Assert.AreEqual("arg1,arg4", this.commandCalls[1]);

            foreach (int i in Enumerable.Range(0, 3))
            {
                this.tick();
            }

            Assert.IsFalse(this.mock.Called);
            Assert.AreEqual(2, this.commandCalls.Count);

            this.tick();

            Assert.IsTrue(this.mock.Called);
        }
Beispiel #3
0
 List <Program.Instruction> getInstructions(Program.MultipleInstruction i) => this.get(i, "instructions") as List <Program.Instruction>;