Ejemplo n.º 1
0
        public void KillWhileInstruction()
        {
            var whileInstruction = new Program.WhileInstruction(
                new Program.WaitInstruction("5"),
                new List <Program.Instruction> {
                new Program.CommandInstruction("cmd", new List <string> {
                    "1"
                }, this.commandLine),
                new Program.CommandInstruction("cmd", new List <string> {
                    "2"
                }, this.commandLine),
                new Program.CommandInstruction("cmd", new List <string> {
                    "3"
                }, this.commandLine),
            }
                );

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

            this.tick();

            Assert.AreEqual(1, this.commandCalls.Count);

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

            Assert.IsTrue(this.mock.Called);
            Assert.AreEqual(1, this.commandCalls.Count);
            Assert.AreEqual("1", string.Join(",", this.commandCalls));

            this.tick();

            Assert.AreEqual(1, this.commandCalls.Count);
        }
Ejemplo n.º 2
0
        public void WhileInstruction()
        {
            var whileInstruction = new Program.WhileInstruction(
                new Program.WaitInstruction("5"),
                new List <Program.Instruction> {
                new Program.CommandInstruction("cmd", new List <string> {
                    "1"
                }, this.commandLine),
                new Program.CommandInstruction("cmd", new List <string> {
                    "2"
                }, this.commandLine),
                new Program.CommandInstruction("cmd", new List <string> {
                    "3"
                }, this.commandLine),
            }
                );

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

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

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

            this.tick();

            Assert.IsTrue(this.mock.Called);
            Assert.AreEqual(4, this.commandCalls.Count);
            Assert.AreEqual("1,2,3,1", string.Join(",", this.commandCalls));

            this.tick();

            Assert.AreEqual(4, this.commandCalls.Count);
        }
Ejemplo n.º 3
0
 Program.SingleInstruction getCondition(Program.WhileInstruction i) => this.get(i, "condition") as Program.SingleInstruction;