Пример #1
0
		/// <summary>
		/// Procedure to add a TestCase object to the ArrayList.
		/// </summary>
		/// <param name="tc">The TestCase object to add.</param>
		public void AddTestCase(TestCase tc)
		{
			// Simply call the Add method on the ArrayList object and pass
			// the TestCase object to it...
			_testCases.Add(tc);
		}
Пример #2
0
		/// <summary>
		/// BuildTestCase builds a TestCase object from the current XML file.
		/// </summary>
		/// <param name="tr">
		/// tr is an XmlTextReader object that already contains the XML from the test file.
		/// </param>
		/// <returns>Returns a complete TestCase object to the caller.
		/// </returns>
		private TestCase BuildTestCase(XmlTextReader tr)
		{
			// make sure the XmlTextReader is not null...
			if(tr == null)
			{
				throw new System.ArgumentNullException("The XML reader is null!");
			}
				// make sure we know where we are in the Xml file. We should be at
				// the first <case> element...
			else if(tr.Name != "case")
			{
				throw new System.ArgumentException("The XML reader is not pointing to the <case> element");
			}

			// Get a TestCase object to build and return...
			TestCase tc = new TestCase();
			
			// we know that we're at a <case> element so do a read to move
			// to the <desc> element...
			tr.Read();

			// we know we've hit the opening <case> element to get here, so now
			// read the file until we've hit the closing </case> element...
			while(tr.Name != "case")
			{
				// make sure the current node is an element...
				if(tr.NodeType == XmlNodeType.Element)
				{
					// grab the description of the TestCase...
					if(tr.Name == "desc")
					{
						// do a read to get to the text portion of the description...
						tr.Read();
						tc.Description = tr.Value;
					}
					// grab the a geometry...
					else if(tr.Name == "a")
					{
						// do a read to move to the text part of the a geometry...
						tr.Read();
						tc.A = tr.Value;
						tc.A = tc.A.Trim();
					}
					// grab the b geometry...
					else if(tr.Name == "b")
					{
						// do a read to move to the text part of the b geometry...
						tr.Read();
						tc.B = tr.Value;
						tc.B = tc.B.Trim();
					}
					// grab the test...
					else if(tr.Name == "test")
					{
						// do a read to move to the <op> element...
						tr.Read();
						// make sure we're at the <op> element...
						if(tr.Name == "op")
						{
							// get the attributes of the <op> element...
							if (tr.HasAttributes)
							{
								string name = string.Empty;
								string arg1 = string.Empty;
								string arg2 = string.Empty;
								string arg3 = string.Empty;
								string result = string.Empty;
								// move through the attributes...
								while (tr.MoveToNextAttribute())
								{
									if(tr.Name == "name")
									{
										name = tr.Value;
									}
									else if(tr.Name == "arg1")
									{
										arg1 = tr.Value;
									}
									else if(tr.Name == "arg2")
									{
										arg2 = tr.Value;
									}
									else if(tr.Name == "arg3")
									{
										arg3 = tr.Value;
									}
								}
								// do another read to move to the expected result...
								tr.Read();
								// trim the spaces of the result...
								result  = tr.Value;
								result = result.Trim();
								result = Test.FormatWKTString(result);

								// add the Test to the TestCase...
								tc.AddTest(name, arg1, arg2, arg3, tc.A, tc.B, result);
							}
						}
					}
				}
				// do a read to the next node...
				tr.Read();
			}
			// return the complete TestCase object...
			return tc;
		}