Ejemplo n.º 1
0
        private void CompareAttributes(DiffResult result, int controlAttributeCount)
        {
            string controlAttrValue, controlAttrName;
            string testAttrValue, testAttrName;

            _controlReader.MoveToFirstAttribute();
            _testReader.MoveToFirstAttribute();
            for (int i = 0; i < controlAttributeCount; ++i)
            {
                controlAttrName = _controlReader.Name;
                testAttrName    = _testReader.Name;

                controlAttrValue = _controlReader.Value;
                testAttrValue    = _testReader.Value;

                if (!String.Equals(controlAttrName, testAttrName))
                {
                    DifferenceFound(DifferenceType.ATTR_SEQUENCE_ID, result);

                    if (!_testReader.MoveToAttribute(controlAttrName))
                    {
                        DifferenceFound(DifferenceType.ATTR_NAME_NOT_FOUND_ID, result);
                    }
                    testAttrValue = _testReader.Value;
                }

                if (!String.Equals(controlAttrValue, testAttrValue))
                {
                    DifferenceFound(DifferenceType.ATTR_VALUE_ID, result);
                }

                _controlReader.MoveToNextAttribute();
                _testReader.MoveToNextAttribute();
            }
        }
Ejemplo n.º 2
0
 private void DifferenceFound(DifferenceType differenceType,
                              XmlNodeType controlNodeType,
                              XmlNodeType testNodeType,
                              DiffResult result)
 {
     DifferenceFound(new Difference(differenceType, controlNodeType, testNodeType),
                     result);
 }
Ejemplo n.º 3
0
 private void DifferenceFound(Difference difference, DiffResult result)
 {
     result.DifferenceFound(this, difference);
     if (!ContinueComparison(difference))
     {
         throw new FlowControlException(difference);
     }
 }
Ejemplo n.º 4
0
 private void CheckEndElement(XmlReader reader, ref bool readResult, DiffResult result)
 {
     readResult = reader.Read();
     if (!readResult || reader.NodeType != XmlNodeType.EndElement)
     {
         DifferenceFound(DifferenceType.CHILD_NODELIST_LENGTH_ID, result);
     }
 }
Ejemplo n.º 5
0
        private void CompareText(DiffResult result)
        {
            string controlText = _controlReader.Value;
            string testText    = _testReader.Value;

            if (!String.Equals(controlText, testText))
            {
                DifferenceFound(DifferenceType.TEXT_VALUE_ID, result);
            }
        }
Ejemplo n.º 6
0
 ///<summary></summary>
 public DiffResult Compare()
 {
     if (_diffResult == null)
     {
         _diffResult = new DiffResult();
         if (!_controlReader.Equals(_testReader))
         {
             Compare(_diffResult);
         }
     }
     return(_diffResult);
 }
Ejemplo n.º 7
0
		///<summary></summary>
		public DiffResult Compare()
		{
			if (_diffResult == null)
			{
				_diffResult = new DiffResult();
				if (!_controlReader.Equals(_testReader))
				{
					Compare(_diffResult);
				}
			}
			return _diffResult;
		}
Ejemplo n.º 8
0
        private void CompareNodes(DiffResult result)
        {
            XmlNodeType controlNodeType = _controlReader.NodeType;
            XmlNodeType testNodeType    = _testReader.NodeType;

            if (!controlNodeType.Equals(testNodeType))
            {
                CheckNodeTypes(controlNodeType, testNodeType, result);
            }
            else if (controlNodeType == XmlNodeType.Element)
            {
                CompareElements(result);
            }
            else if (controlNodeType == XmlNodeType.Text)
            {
                CompareText(result);
            }
        }
Ejemplo n.º 9
0
 private void CheckEmptyOrAtEndElement(DiffResult result,
                                       ref bool controlRead, ref bool testRead)
 {
     if (_controlReader.IsEmptyElement)
     {
         if (!_testReader.IsEmptyElement)
         {
             CheckEndElement(_testReader, ref testRead, result);
         }
     }
     else
     {
         if (_testReader.IsEmptyElement)
         {
             CheckEndElement(_controlReader, ref controlRead, result);
         }
     }
 }
Ejemplo n.º 10
0
        private void Compare(DiffResult result)
        {
            bool controlRead, testRead;

            try
            {
                do
                {
                    controlRead = _controlReader.Read();
                    testRead    = _testReader.Read();
                    Compare(result, ref controlRead, ref testRead);
                } while (controlRead && testRead);
            }
            catch (FlowControlException e)
            {
                Console.Out.WriteLine(e.Message);
            }
        }
Ejemplo n.º 11
0
 private void Compare(DiffResult result, ref bool controlRead, ref bool testRead)
 {
     if (controlRead)
     {
         if (testRead)
         {
             CompareNodes(result);
             CheckEmptyOrAtEndElement(result, ref controlRead, ref testRead);
         }
         else
         {
             DifferenceFound(DifferenceType.CHILD_NODELIST_LENGTH_ID, result);
         }
     }
     //jh added this; under a condition I haven't got into an xdiff test yet, the
     // 'test' guy still had more children, and this fact was being missed by the above code
     if (controlRead != testRead)
     {
         DifferenceFound(DifferenceType.CHILD_NODELIST_LENGTH_ID, result);
     }
 }
Ejemplo n.º 12
0
        private void CompareElements(DiffResult result)
        {
            string controlTagName = _controlReader.Name;
            string testTagName    = _testReader.Name;

            if (!String.Equals(controlTagName, testTagName))
            {
                DifferenceFound(DifferenceType.ELEMENT_TAG_NAME_ID, result);
            }
            else
            {
                int controlAttributeCount = _controlReader.AttributeCount;
                int testAttributeCount    = _testReader.AttributeCount;
                if (controlAttributeCount != testAttributeCount)
                {
                    DifferenceFound(DifferenceType.ELEMENT_NUM_ATTRIBUTES_ID, result);
                }
                else
                {
                    CompareAttributes(result, controlAttributeCount);
                }
            }
        }
Ejemplo n.º 13
0
		private void Compare(DiffResult result, ref bool controlRead, ref bool testRead)
		{
			if (controlRead)
			{
				if (testRead)
				{
					CompareNodes(result);
					CheckEmptyOrAtEndElement(result, ref controlRead, ref testRead);
				}
				else
				{
					DifferenceFound(DifferenceType.CHILD_NODELIST_LENGTH_ID, result);
				}
			}
			//jh added this; under a condition I haven't got into an xdiff test yet, the
			// 'test' guy still had more children, and this fact was being missed by the above code
			if (controlRead != testRead)
			{
					DifferenceFound(DifferenceType.CHILD_NODELIST_LENGTH_ID, result);
			}
		}
Ejemplo n.º 14
0
		private void CheckNodeTypes(XmlNodeType controlNodeType, XmlNodeType testNodeType, DiffResult result)
		{
			XmlReader readerToAdvance = null;
			if (controlNodeType.Equals(XmlNodeType.XmlDeclaration))
			{
				readerToAdvance = _controlReader;
			}
			else if (testNodeType.Equals(XmlNodeType.XmlDeclaration))
			{
				readerToAdvance = _testReader;
			}

			if (readerToAdvance != null)
			{
				DifferenceFound(DifferenceType.HAS_XML_DECLARATION_PREFIX_ID,
								controlNodeType, testNodeType, result);
				readerToAdvance.Read();
				CompareNodes(result);
			}
			else
			{
				DifferenceFound(DifferenceType.NODE_TYPE_ID, controlNodeType,
								testNodeType, result);
			}
		}
Ejemplo n.º 15
0
		private void CompareElements(DiffResult result)
		{
			string controlTagName = _controlReader.Name;
			string testTagName = _testReader.Name;
			if (!String.Equals(controlTagName, testTagName))
			{
				DifferenceFound(DifferenceType.ELEMENT_TAG_NAME_ID, result);
			}
			else
			{
				int controlAttributeCount = _controlReader.AttributeCount;
				int testAttributeCount = _testReader.AttributeCount;
				if (controlAttributeCount != testAttributeCount)
				{
					DifferenceFound(DifferenceType.ELEMENT_NUM_ATTRIBUTES_ID, result);
				}
				else
				{
					CompareAttributes(result, controlAttributeCount);
				}
			}
		}
Ejemplo n.º 16
0
		private void CompareAttributes(DiffResult result, int controlAttributeCount)
		{
			string controlAttrValue, controlAttrName;
			string testAttrValue, testAttrName;

			_controlReader.MoveToFirstAttribute();
			_testReader.MoveToFirstAttribute();
			for (int i = 0; i < controlAttributeCount; ++i)
			{

				controlAttrName = _controlReader.Name;
				testAttrName = _testReader.Name;

				controlAttrValue = _controlReader.Value;
				testAttrValue = _testReader.Value;

				if (!String.Equals(controlAttrName, testAttrName))
				{
					DifferenceFound(DifferenceType.ATTR_SEQUENCE_ID, result);

					if (!_testReader.MoveToAttribute(controlAttrName))
					{
						DifferenceFound(DifferenceType.ATTR_NAME_NOT_FOUND_ID, result);
					}
					testAttrValue = _testReader.Value;
				}

				if (!String.Equals(controlAttrValue, testAttrValue))
				{
					DifferenceFound(DifferenceType.ATTR_VALUE_ID, result);
				}

				_controlReader.MoveToNextAttribute();
				_testReader.MoveToNextAttribute();
			}
		}
Ejemplo n.º 17
0
		private void CompareText(DiffResult result)
		{
			string controlText = _controlReader.Value;
			string testText = _testReader.Value;
			if (!String.Equals(controlText, testText))
			{
				DifferenceFound(DifferenceType.TEXT_VALUE_ID, result);
			}
		}
Ejemplo n.º 18
0
		private void DifferenceFound(DifferenceType differenceType, DiffResult result)
		{
			DifferenceFound(new Difference(differenceType), result);
		}
Ejemplo n.º 19
0
 private void DifferenceFound(DifferenceType differenceType, DiffResult result)
 {
     DifferenceFound(new Difference(differenceType), result);
 }
Ejemplo n.º 20
0
		private void DifferenceFound(Difference difference, DiffResult result)
		{
			result.DifferenceFound(this, difference);
			if (!ContinueComparison(difference))
			{
				throw new FlowControlException(difference);
			}
		}
Ejemplo n.º 21
0
		private void DifferenceFound(DifferenceType differenceType,
									 XmlNodeType controlNodeType,
									 XmlNodeType testNodeType,
									 DiffResult result)
		{
			DifferenceFound(new Difference(differenceType, controlNodeType, testNodeType),
							result);
		}
Ejemplo n.º 22
0
        private void CheckNodeTypes(XmlNodeType controlNodeType, XmlNodeType testNodeType, DiffResult result)
        {
            XmlReader readerToAdvance = null;

            if (controlNodeType.Equals(XmlNodeType.XmlDeclaration))
            {
                readerToAdvance = _controlReader;
            }
            else if (testNodeType.Equals(XmlNodeType.XmlDeclaration))
            {
                readerToAdvance = _testReader;
            }

            if (readerToAdvance != null)
            {
                DifferenceFound(DifferenceType.HAS_XML_DECLARATION_PREFIX_ID,
                                controlNodeType, testNodeType, result);
                readerToAdvance.Read();
                CompareNodes(result);
            }
            else
            {
                DifferenceFound(DifferenceType.NODE_TYPE_ID, controlNodeType,
                                testNodeType, result);
            }
        }
Ejemplo n.º 23
0
		private void CheckEmptyOrAtEndElement(DiffResult result,
											  ref bool controlRead, ref bool testRead)
		{
			if (_controlReader.IsEmptyElement)
			{
				if (!_testReader.IsEmptyElement)
				{
					CheckEndElement(_testReader, ref testRead, result);
				}
			}
			else
			{
				if (_testReader.IsEmptyElement)
				{
					CheckEndElement(_controlReader, ref controlRead, result);
				}
			}
		}
Ejemplo n.º 24
0
		private void CompareNodes(DiffResult result)
		{
			XmlNodeType controlNodeType = _controlReader.NodeType;
			XmlNodeType testNodeType = _testReader.NodeType;
			if (!controlNodeType.Equals(testNodeType))
			{
				CheckNodeTypes(controlNodeType, testNodeType, result);
			}
			else if (controlNodeType == XmlNodeType.Element)
			{
				CompareElements(result);
			}
			else if (controlNodeType == XmlNodeType.Text)
			{
				CompareText(result);
			}
		}
Ejemplo n.º 25
0
		private void Compare(DiffResult result)
		{
			bool controlRead, testRead;
			try
			{
				do
				{
					controlRead = _controlReader.Read();
					testRead = _testReader.Read();
					Compare(result, ref controlRead, ref testRead);
				} while (controlRead && testRead);
			}
			catch (FlowControlException e)
			{
				Console.Out.WriteLine(e.Message);
			}
		}
Ejemplo n.º 26
0
		private void CheckEndElement(XmlReader reader, ref bool readResult, DiffResult result)
		{
			readResult = reader.Read();
			if (!readResult || reader.NodeType != XmlNodeType.EndElement)
			{
				DifferenceFound(DifferenceType.CHILD_NODELIST_LENGTH_ID, result);
			}
		}