public void Parse() { List <Program.AutoRoutine> routines = this.parser.Parse(@" ; line to be ignored = Test routine wait 10 -cmd arg while forever -cmd arg2 -cmd arg3 ""test test"" wait 100 end =Test routine 2 while -cmd arg4 -cmd arg5 while -cmd arg6 -cmd arg7 end end "); Assert.AreEqual(2, routines.Count); Program.AutoRoutine routine1 = routines[0]; Program.AutoRoutine routine2 = routines[1]; Assert.AreEqual("Test routine", routine1.Name); List <Program.Instruction> instructions = this.getInstructions(routine1); Assert.AreEqual(3, instructions.Count); Assert.AreEqual("10", this.getTime(instructions[0] as Program.WaitInstruction)); Assert.AreEqual("cmd", this.getCmd(instructions[1] as Program.CommandInstruction)); Assert.IsTrue(new List <string> { "arg" }.SequenceEqual(this.getArgs(instructions[1] as Program.CommandInstruction))); Assert.IsInstanceOfType(this.getCondition(instructions[2] as Program.WhileInstruction), typeof(Program.ForeverInstruction)); instructions = this.getInstructions(instructions[2] as Program.MultipleInstruction); Assert.AreEqual(3, instructions.Count); Assert.IsInstanceOfType(instructions[0], typeof(Program.CommandInstruction)); Assert.AreEqual("cmd", this.getCmd(instructions[1] as Program.CommandInstruction)); Assert.IsTrue(new List <string> { "arg3", "test test" }.SequenceEqual(this.getArgs(instructions[1] as Program.CommandInstruction))); Assert.AreEqual("100", this.getTime(instructions[2] as Program.WaitInstruction)); Assert.AreEqual(0, routine1.ArgsCount()); Assert.AreEqual("Test routine 2", routine2.Name); Assert.AreEqual(0, routine2.ArgsCount()); }
public void ParsePlaceholders() { List <Program.AutoRoutine> routines = this.parser.Parse(@" ; line to be ignored = Test routine wait $2 -cmd $1 while wait $3 -cmd $1 $4 end "); Assert.AreEqual(1, routines.Count); Program.AutoRoutine routine = routines[0]; Assert.AreEqual(4, routine.ArgsCount()); }