Ejemplo n.º 1
0
        public void evalFunction()
        {
            TestState ts = TestState.getOnly("LT");

            ts.Script = "UtilitiesTest.xml";
            SelectText ins1 = new SelectText();

            ts.AddNamedInstruction("one", ins1);
            ins1.Path = "window:cleaner/item:dust";
            // note: ins1 has no default data set (ie. $one.text = null)
            Var ins2 = new Var();

            ts.AddNamedInstruction("_two", ins2);
            ins2.Set = " how's this??";
            Var ins3 = new Var();

            ts.AddNamedInstruction("thr-ee", ins3);
            ins3.Set = "And $_two; this should be ignored?";

            ins2.Execute();
            ins3.Execute();

            string result = Utilities.evalExpr("$random()");

            Assert.IsTrue(result == "0" || result == "1", "default random not 0 or 1");
            result = Utilities.evalExpr("$random(,)");
            Assert.IsTrue(result == "$random(,)", "random can't just have a comma for an argument");
            result = Utilities.evalExpr("$random(,4)");
            Assert.IsTrue(result == "$random(,4)", "random has to have a max argument");
            result = Utilities.evalExpr("$random(4,)");
            Assert.IsTrue(result == "$random(4,)", "random has to have a min argument when there's a comma");
            result = Utilities.evalExpr("$random(45,50)");
            Assert.IsTrue(result == "$random(45,50)", "min has to be less than max");
            result = Utilities.evalExpr("$random(50,45)");
            Assert.IsTrue(result == "45" || result == "46" || result == "47" ||
                          result == "48" || result == "49" || result == "50",
                          "Random must be between 45 and 50");
            result = Utilities.evalExpr("$random(-6,-10)");
            Assert.IsTrue(result == "-6" || result == "-7" || result == "-8" ||
                          result == "-9" || result == "-10",
                          "Random must be between -10 and -6");
            result = Utilities.evalExpr("$random(3,-2)");
            Assert.IsTrue(result == "-2" || result == "-1" || result == "0" ||
                          result == "1" || result == "2" || result == "3",
                          "Random must be between -2 and 3");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a select-text instruction.
        /// </summary>
        /// <param name="xn">The XML repersentation of the instruction to be checked</param>
        /// <param name="con">The current context object</param>
        static SelectText CreateSelectText(XmlNode xn, Context con)
        {
            SelectText sel = new SelectText();

            sel.Path = XmlFiler.getAttribute(xn, "path");
            Logger.getOnly().isNotNull(sel.Path, "Select-text instruction must have a path.");
            Logger.getOnly().isTrue(sel.Path != "", "Select-text instruction must have a non-empty path.");
            sel.Loc = XmlFiler.getAttribute(xn, "loc");
            string sAt = XmlFiler.getAttribute(xn, "at");

            if (sAt == null)
            {
                sel.At = 0;
            }
            else
            {
                sel.At = Convert.ToInt32(sAt);
            }
            string sRun = XmlFiler.getAttribute(xn, "run");

            if (sRun == null)
            {
                sel.Run = 0;
            }
            else
            {
                sel.Run = Convert.ToInt32(sRun);
            }
            string rest = XmlFiler.getAttribute(xn, "wait");

            if (rest != null)
            {
                sel.Rest = Convert.ToInt32(rest);
            }
            AddInstruction(xn, sel, con);
            return(sel);
        }
Ejemplo n.º 3
0
		/// <summary>
		/// Creates a select-text instruction.
		/// </summary>
		/// <param name="xn">The XML repersentation of the instruction to be checked</param>
		/// <param name="con">The current context object</param>
		static SelectText CreateSelectText(XmlNode xn, Context con)
		{
			SelectText sel = new SelectText();
			sel.Path = XmlFiler.getAttribute(xn, "path");
			Logger.getOnly().isNotNull(sel.Path, "Select-text instruction must have a path.");
			Logger.getOnly().isTrue(sel.Path != "", "Select-text instruction must have a non-empty path.");
			sel.Loc = XmlFiler.getAttribute(xn, "loc");
			string sAt = XmlFiler.getAttribute(xn, "at");
			if (sAt == null) sel.At = 0;
			else             sel.At = Convert.ToInt32(sAt);
			string sRun = XmlFiler.getAttribute(xn, "run");
			if (sRun == null) sel.Run = 0;
			else              sel.Run = Convert.ToInt32(sRun);
			string rest = XmlFiler.getAttribute(xn, "wait");
			if (rest != null) sel.Rest = Convert.ToInt32(rest);
			AddInstruction(xn, sel, con);
			return sel;
		}
Ejemplo n.º 4
0
		public void evalFunction()
		{
			TestState ts = TestState.getOnly("LT");
			ts.Script = "UtilitiesTest.xml";
			SelectText ins1 = new SelectText();
			ts.AddNamedInstruction("one", ins1);
			ins1.Path = "window:cleaner/item:dust";
			// note: ins1 has no default data set (ie. $one.text = null)
			Var ins2 = new Var();
			ts.AddNamedInstruction("_two", ins2);
			ins2.Set = " how's this??";
			Var ins3 = new Var();
			ts.AddNamedInstruction("thr-ee", ins3);
			ins3.Set = "And $_two; this should be ignored?";

			ins2.Execute();
			ins3.Execute();

			string result = Utilities.evalExpr("$random()");
			Assert.IsTrue(result == "0" || result == "1", "default random not 0 or 1");
			result = Utilities.evalExpr("$random(,)");
			Assert.IsTrue(result == "$random(,)", "random can't just have a comma for an argument");
			result = Utilities.evalExpr("$random(,4)");
			Assert.IsTrue(result == "$random(,4)", "random has to have a max argument");
			result = Utilities.evalExpr("$random(4,)");
			Assert.IsTrue(result == "$random(4,)", "random has to have a min argument when there's a comma");
			result = Utilities.evalExpr("$random(45,50)");
			Assert.IsTrue(result == "$random(45,50)", "min has to be less than max");
			result = Utilities.evalExpr("$random(50,45)");
			Assert.IsTrue(result == "45" || result == "46" || result == "47" ||
						  result == "48" || result == "49" || result == "50",
				"Random must be between 45 and 50");
			result = Utilities.evalExpr("$random(-6,-10)");
			Assert.IsTrue(result == "-6" || result == "-7" || result == "-8" ||
						  result == "-9" || result == "-10",
				"Random must be between -10 and -6");
			result = Utilities.evalExpr("$random(3,-2)");
			Assert.IsTrue(result == "-2" || result == "-1" || result == "0" ||
						  result == "1" || result == "2" || result == "3",
				"Random must be between -2 and 3");
		}
Ejemplo n.º 5
0
		public void evalExpr()
		{
			TestState ts = TestState.getOnly("LT");
			ts.Script = "UtilitiesTest.xml";
			SelectText ins1 = new SelectText();
			ts.AddNamedInstruction("one",ins1);
			ins1.Path = "window:cleaner/item:dust";
			// note: ins1 has no default data set (ie. $one.text = null)
			Var ins2 = new Var();
			ts.AddNamedInstruction("_two",ins2);
			ins2.Set = " how's this??";
			Var ins3 = new Var();
			ts.AddNamedInstruction("thr-ee",ins3);
			ins3.Set = "And $_two; this should be ignored?";

			ins2.Execute();
			ins3.Execute();

			string result = Utilities.evalExpr("$one");
			Assert.AreEqual(null,result);
			result = Utilities.evalExpr("$one;");
			Assert.AreEqual(null,result);
			result = Utilities.evalExpr("$one ");
			Assert.AreEqual(" ",result);
			result = Utilities.evalExpr(" $one");
			Assert.AreEqual(" ",result);
			result = Utilities.evalExpr("$one; ");
			Assert.AreEqual(" ",result);
			result = Utilities.evalExpr(";$one; ");
			Assert.AreEqual("; ",result);
			result = Utilities.evalExpr(";$one;;");
			Assert.AreEqual(";;",result);
			result = Utilities.evalExpr("$one1");
			Assert.AreEqual("$one1",result);
			result = Utilities.evalExpr("$on;e");
			Assert.AreEqual("$on;e",result);

			result = Utilities.evalExpr("$_two");
			Assert.AreEqual(" how's this??",result);
			result = Utilities.evalExpr("$_two;");
			Assert.AreEqual(" how's this??",result);
			result = Utilities.evalExpr("$_two ");
			Assert.AreEqual(" how's this?? ",result);
			result = Utilities.evalExpr(" $_two");
			Assert.AreEqual("  how's this??",result);
			result = Utilities.evalExpr("$_two; ");
			Assert.AreEqual(" how's this?? ",result);
			result = Utilities.evalExpr(";$_two; ");
			Assert.AreEqual("; how's this?? ",result);
			result = Utilities.evalExpr(";$_two;;");
			Assert.AreEqual("; how's this??;",result);
			result = Utilities.evalExpr("$_two1");
			Assert.AreEqual("$_two1",result);
			result = Utilities.evalExpr("$_tw;o");
			Assert.AreEqual("$_tw;o",result);

			result = Utilities.evalExpr("$one.;");
			Assert.AreEqual(null,result);
			result = Utilities.evalExpr("$one..;");
			Assert.AreEqual("[select-text-1 does not have data for '.']",result);
			result = Utilities.evalExpr("$one.path");
			Assert.AreEqual("window:cleaner/item:dust",result);
			result = Utilities.evalExpr("$one.path;");
			Assert.AreEqual("window:cleaner/item:dust",result);
			result = Utilities.evalExpr("$one.path.;");
			Assert.AreEqual("[select-text-1 does not have data for 'path.']",result);

			result = Utilities.evalExpr("text$one;$_two;$thr-ee");
			Assert.AreEqual("text how's this??And  how's this?? this should be ignored?",result);
			result = Utilities.evalExpr("text$one;$_two;$thr-ee");
			Assert.AreEqual("text how's this??And  how's this?? this should be ignored?",result);
			result = Utilities.evalExpr("text$one.path;$_two;$thr-ee OK");
			Assert.AreEqual("textwindow:cleaner/item:dust how's this??And  how's this?? this should be ignored? OK",result);
			result = Utilities.evalExpr("text $_two $one.path OK");
			Assert.AreEqual("text  how's this?? window:cleaner/item:dust OK",result);
		}
Ejemplo n.º 6
0
        public void evalExpr()
        {
            TestState ts = TestState.getOnly("LT");

            ts.Script = "UtilitiesTest.xml";
            SelectText ins1 = new SelectText();

            ts.AddNamedInstruction("one", ins1);
            ins1.Path = "window:cleaner/item:dust";
            // note: ins1 has no default data set (ie. $one.text = null)
            Var ins2 = new Var();

            ts.AddNamedInstruction("_two", ins2);
            ins2.Set = " how's this??";
            Var ins3 = new Var();

            ts.AddNamedInstruction("thr-ee", ins3);
            ins3.Set = "And $_two; this should be ignored?";

            ins2.Execute();
            ins3.Execute();

            string result = Utilities.evalExpr("$one");

            Assert.AreEqual(null, result);
            result = Utilities.evalExpr("$one;");
            Assert.AreEqual(null, result);
            result = Utilities.evalExpr("$one ");
            Assert.AreEqual(" ", result);
            result = Utilities.evalExpr(" $one");
            Assert.AreEqual(" ", result);
            result = Utilities.evalExpr("$one; ");
            Assert.AreEqual(" ", result);
            result = Utilities.evalExpr(";$one; ");
            Assert.AreEqual("; ", result);
            result = Utilities.evalExpr(";$one;;");
            Assert.AreEqual(";;", result);
            result = Utilities.evalExpr("$one1");
            Assert.AreEqual("$one1", result);
            result = Utilities.evalExpr("$on;e");
            Assert.AreEqual("$on;e", result);

            result = Utilities.evalExpr("$_two");
            Assert.AreEqual(" how's this??", result);
            result = Utilities.evalExpr("$_two;");
            Assert.AreEqual(" how's this??", result);
            result = Utilities.evalExpr("$_two ");
            Assert.AreEqual(" how's this?? ", result);
            result = Utilities.evalExpr(" $_two");
            Assert.AreEqual("  how's this??", result);
            result = Utilities.evalExpr("$_two; ");
            Assert.AreEqual(" how's this?? ", result);
            result = Utilities.evalExpr(";$_two; ");
            Assert.AreEqual("; how's this?? ", result);
            result = Utilities.evalExpr(";$_two;;");
            Assert.AreEqual("; how's this??;", result);
            result = Utilities.evalExpr("$_two1");
            Assert.AreEqual("$_two1", result);
            result = Utilities.evalExpr("$_tw;o");
            Assert.AreEqual("$_tw;o", result);

            result = Utilities.evalExpr("$one.;");
            Assert.AreEqual(null, result);
            result = Utilities.evalExpr("$one..;");
            Assert.AreEqual("[select-text-1 does not have data for '.']", result);
            result = Utilities.evalExpr("$one.path");
            Assert.AreEqual("window:cleaner/item:dust", result);
            result = Utilities.evalExpr("$one.path;");
            Assert.AreEqual("window:cleaner/item:dust", result);
            result = Utilities.evalExpr("$one.path.;");
            Assert.AreEqual("[select-text-1 does not have data for 'path.']", result);

            result = Utilities.evalExpr("text$one;$_two;$thr-ee");
            Assert.AreEqual("text how's this??And  how's this?? this should be ignored?", result);
            result = Utilities.evalExpr("text$one;$_two;$thr-ee");
            Assert.AreEqual("text how's this??And  how's this?? this should be ignored?", result);
            result = Utilities.evalExpr("text$one.path;$_two;$thr-ee OK");
            Assert.AreEqual("textwindow:cleaner/item:dust how's this??And  how's this?? this should be ignored? OK", result);
            result = Utilities.evalExpr("text $_two $one.path OK");
            Assert.AreEqual("text  how's this?? window:cleaner/item:dust OK", result);
        }