Пример #1
0
		/// <summary>
		/// Gets the name of a test script and runs it.
		/// There must be a corresponding XML script file in the
		/// location specified in the GtdConfig.xml file.
		/// </summary>
		/// <param name="script">The name of the test script (.xml not needed).</param>
		public void fromFile(string script)
		{
			if(!(script.ToLower()).EndsWith(@".xml"))
				script += ".xml";
			TestState ts = null;
			if (varsDefined)
			{
				ts = TestState.getOnly();
				// Re-open the log using the script name - lose what's there.
				Logger.getOnly().close();
				// The next call to Logger.getOnly() will create one with using the script name.
			}
			else ts = TestState.getOnly(m_appSymbol); // Allocating ts here insures deallocation
			ts.Script = script; // must come before ts.PublishVars();
			ts.PublishVars();

			// get the script path from the configuration file
			string path = ts.getScriptPath() + @"\" + script;
			XmlElement scriptRoot = XmlFiler.getDocumentElement(path, "accil", false);
			Assert.IsNotNull(scriptRoot, "Missing document element 'accil'.");
			Desktop dt = new Desktop();
			Assert.IsNotNull(dt, "Desktop not created for script " + path);
			dt.Element = scriptRoot; // not quite code-behind, but OK
			dt.Number = ts.IncInstructionCount;
			//dt = new XmlInstructionBuilder().Parse(path);

			// now execute any variables if they've been added before executing the desktop
			foreach (Var v in m_vars)
			{
				v.Execute();
			}

			System.GC.Collect(); // forces collection on NUnit process only

			dt.Execute();
			varsDefined = false; // the next test may not have any
			Logger.getOnly().close();
			Thread.Sleep(1000);
		}
Пример #2
0
		public void Init()
		{
			TestState ts = TestState.getOnly("LT");
			ts.Script = "DesktopTest.xml";
			m_dsk = new Desktop();
		}
Пример #3
0
		/// <summary>
		/// Creates a desktop context instruction.
		/// </summary>
		/// <param name="xn">The XML repersentation of the instruction to be created</param>
		/// <param name="con">The current context object</param>
		static Desktop CreateDesktopContext(XmlNode xn, Context con)
		{
			Desktop dt = new Desktop();
			string rest = XmlFiler.getAttribute(xn, "wait");
			if (rest != null) dt.Rest = Convert.ToInt32(rest);
			dt.OnPass = XmlFiler.getAttribute(xn, "on-pass");
			dt.OnFail = XmlFiler.getAttribute(xn, "on-fail");
			dt.ModelNode = con.ModelNode;
			AddInstruction(xn, dt, con);
/*			foreach (XmlNode xnChild in xn.ChildNodes)
			{
				InterpretChild(xnChild, dt);
			}
*/
			return dt;
		}
Пример #4
0
		public void PassFailAncestorContext(string PassIn, string FailIn, out string onPass, out string onFail)
		{
			// Set up a typical instruction tree.
			TestState ts = TestState.getOnly("LT");
			ts.Script = "ApplicationContextTest.xml";
			NoOp op1 = new NoOp();
			NoOp op2 = new NoOp();
			NoOp op3 = new NoOp();
			Desktop Desk = new Desktop();
			Desk.OnPass = PassIn;
			Desk.OnFail = FailIn;
			Desk.Add(op1);
			op1.Parent = Desk;
			Desk.Add(op2);
			op2.Parent = Desk;
			Desk.Add(op3);
			op3.Parent = Desk;
			ApplicationContext ac = MakeAppContext();
			ts.AddNamedInstruction("Find me",ac);
			ApplicationContext AppCon = new ApplicationContext();
			AppCon.SetSource("Find me");
			Assert.AreEqual(ac,(ApplicationContext)AppCon.TestGetOfSource(),"Context source not set right");
			Desk.Add(AppCon);
			AppCon.Parent = Desk;
			NoOp ins1 = new NoOp();
			NoOp ins2 = new NoOp();
			NoOp ins3 = new NoOp();
			AppCon.Add(ins1);
			ins1.Parent = AppCon;
			AppCon.Add(ins2);
			ins2.Parent = AppCon;
			AppCon.Add(ins3);
			ins3.Parent = AppCon;
			ins2.PassFailInContext(null,null,out onPass,out onFail);
		}