Esempio 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 (controlAttrName != testAttrName)
                {
                    DifferenceFound(DifferenceType.AttributeSequence, result);

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

                if (controlAttrValue != testAttrValue)
                {
                    DifferenceFound(DifferenceType.AttributeValue, result);
                }

                _controlReader.MoveToNextAttribute();
                _testReader.MoveToNextAttribute();
            }
        }
 public void CreateDiffResult()
 {
     _result = new DiffResult();
     _diff = new XmlDiff("<a/>", "<b/>");
     _majorDifference = new Difference(DifferenceType.ElementTagName, XmlNodeType.Element, XmlNodeType.Element);
     _minorDifference = new Difference(DifferenceType.AttributeSequence, XmlNodeType.Comment, XmlNodeType.Comment);
 }
Esempio n. 3
0
        private void DifferenceFound(Difference difference, DiffResult result)
        {
            result.DifferenceFound(this, difference);

            //if (!ContinueComparison(difference)) {
            //    throw new FlowControlException(difference);
            //}
        }
Esempio n. 4
0
 private void DifferenceFound(DifferenceType differenceType,
                              XmlNodeType controlNodeType,
                              XmlNodeType testNodeType,
                              DiffResult result)
 {
     DifferenceFound(new Difference(differenceType, controlNodeType, testNodeType),
                     result);
 }
Esempio n. 5
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);
     }
 }
Esempio n. 6
0
        private void CompareText(DiffResult result)
        {
            string controlText = _controlReader.Value;
            string testText    = _testReader.Value;

            if (controlText != testText)
            {
                DifferenceFound(DifferenceType.TEXT_VALUE_ID, result);
            }
        }
Esempio n. 7
0
        private void Compare(DiffResult result)
        {
            bool controlRead, testRead;

            do
            {
                controlRead = _controlReader.Read();
                testRead    = _testReader.Read();
                Compare(result, ref controlRead, ref testRead);
            } while (controlRead && testRead);
        }
Esempio n. 8
0
 public DiffResult Compare()
 {
     if (_diffResult == null)
     {
         _diffResult = new DiffResult();
         if (!_controlReader.Equals(_testReader))
         {
             Compare(_diffResult);
         }
     }
     return(_diffResult);
 }
Esempio n. 9
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);
         }
     }
 }
Esempio 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);
                throw;
            }
        }
Esempio n. 11
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);
            }
        }
Esempio n. 12
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);
         }
     }
 }
Esempio n. 13
0
        private void CompareElements(DiffResult result)
        {
            string controlTagName = _controlReader.Name;
            string testTagName    = _testReader.Name;

            if (controlTagName != testTagName)
            {
                DifferenceFound(DifferenceType.ElementTagName, result);
            }
            else
            {
                int controlAttributeCount = _controlReader.AttributeCount;
                int testAttributeCount    = _testReader.AttributeCount;
                if (controlAttributeCount != testAttributeCount)
                {
                    DifferenceFound(DifferenceType.ELEMENT_NUM_ATTRIBUTES_ID, result);
                }
                else
                {
                    CompareAttributes(result, controlAttributeCount);
                }
            }
        }
Esempio n. 14
0
 private void DifferenceFound(DifferenceType differenceType, DiffResult result)
 {
     DifferenceFound(new Difference(differenceType), result);
 }
Esempio n. 15
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);
     }
 }
Esempio n. 16
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);
 		}       
     }
Esempio n. 17
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);
            }
        }
Esempio n. 18
0
 private void DifferenceFound(DifferenceType differenceType, 
                              XmlNodeType controlNodeType,
                              XmlNodeType testNodeType, 
                              DiffResult result) {
     DifferenceFound(new Difference(differenceType, controlNodeType, testNodeType),
                     result);
 }
Esempio n. 19
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 (controlAttrName!=testAttrName) {
                    DifferenceFound(DifferenceType.AttributeSequence, result);
                
                    if (!_testReader.MoveToAttribute(controlAttrName)) {
                        DifferenceFound(DifferenceType.AttributeNameNotFound, result);
                    }
                    testAttrValue = _testReader.Value;
                }
                
                if (controlAttrValue!=testAttrValue) 
				{
                    DifferenceFound(DifferenceType.AttributeValue, result);
                }
                
                _controlReader.MoveToNextAttribute();
                _testReader.MoveToNextAttribute();
            }
        }
Esempio n. 20
0
 private void CompareText(DiffResult result) {
     string controlText = _controlReader.Value;
     string testText = _testReader.Value;
     if (controlText!=testText) {
         DifferenceFound(DifferenceType.TEXT_VALUE_ID, result);
     }
 }
Esempio n. 21
0
 private void DifferenceFound(DifferenceType differenceType, DiffResult result) {
     DifferenceFound(new Difference(differenceType), result);
 }
Esempio n. 22
0
 public DiffResult Compare() {
     if (_diffResult == null) {
         _diffResult = new DiffResult();
         if (!_controlReader.Equals(_testReader)) {
             Compare(_diffResult);
         }
     }
     return _diffResult;
 }
Esempio n. 23
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);
     }        
 }
Esempio n. 24
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);
         }
     }
 }
Esempio n. 25
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);
         } 
     }
 }
Esempio n. 26
0
 private void Compare(DiffResult result) {
     bool controlRead, testRead;
     do {
         controlRead = _controlReader.Read();
         testRead = _testReader.Read();
     	Compare(result, ref controlRead, ref testRead);
     } while (controlRead && testRead) ;
 }        
Esempio n. 27
0
        private void CompareElements(DiffResult result) {
            string controlTagName = _controlReader.Name;
            string testTagName = _testReader.Name;
            if (controlTagName!=testTagName) {
                DifferenceFound(DifferenceType.ElementTagName, result);
            } 
			else 
			{
                int controlAttributeCount = _controlReader.AttributeCount;
                int testAttributeCount = _testReader.AttributeCount;
                if (controlAttributeCount != testAttributeCount) {
                    DifferenceFound(DifferenceType.ELEMENT_NUM_ATTRIBUTES_ID, result);
                } else {
                    CompareAttributes(result, controlAttributeCount);
                }
            }
        }
Esempio n. 28
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);
				throw;
            }
        }        
Esempio n. 29
0
 private void DifferenceFound(Difference difference, DiffResult result) {
     result.DifferenceFound(this, difference);
     
     //if (!ContinueComparison(difference)) {
     //    throw new FlowControlException(difference);
     //}
 }