private void BuildChildrenElementResponses(ComparisonXmlElement toCompare, List <AreEquivalentResponse> responses)
        {
            //Compare all children elements
            //Are they missing elements?
            var missingElementsOnPrimary    = Children.Keys.Except(toCompare.Children.Keys);
            var missingElementsOnComparison = toCompare.Children.Keys.Except(Children.Keys);

            if (missingElementsOnPrimary.Any())
            {
                responses.Add(new AreEquivalentResponse(false,
                                                        String.Format("{0}/-> Elements missing from document: {1}", GetFullPath(),
                                                                      missingElementsOnPrimary.Aggregate((x, y) => x + ", " + y))));
            }
            if (missingElementsOnComparison.Any())
            {
                responses.Add(new AreEquivalentResponse(false,
                                                        String.Format("{0}/-> Elements missing from document: {1}", toCompare.GetFullPath(),
                                                                      missingElementsOnComparison.Aggregate((x, y) => x + ", " + y))));
            }

            //Are the elements equivalent?
            foreach (var child in Children)
            {
                ComparisonXmlElement toCompareChild;
                toCompare.Children.TryGetValue(child.Key, out toCompareChild);
                if (toCompareChild == null)
                {
                    continue;
                }

                var response = child.Value.IsElementEquivalent(toCompareChild);

                responses.AddRange(response);
            }
        }
        private void BuildAttributeResponses(ComparisonXmlElement toCompare, List <AreEquivalentResponse> responses)
        {
            var missingAttributesOnPrimary = Attributes.Keys.Except(toCompare.Attributes.Keys);

            if (missingAttributesOnPrimary.Any())
            {
                responses.Add(new AreEquivalentResponse(false,
                                                        String.Format("{0}/-> Attributes missing: {1}", GetFullPath(),
                                                                      missingAttributesOnPrimary.Aggregate((x, y) => x + ", " + y))));
            }
            var missingAttributesOnComparison = toCompare.Attributes.Keys.Except(Attributes.Keys);

            if (missingAttributesOnComparison.Any())
            {
                responses.Add(new AreEquivalentResponse(false,
                                                        String.Format("{0}/-> Attributes missing: {1}", toCompare.GetFullPath(),
                                                                      missingAttributesOnComparison.Aggregate((x, y) => x + ", " + y))));
            }

            var toCompareAttributes = toCompare.Attributes;

            foreach (var attribute in Attributes)
            {
                ComparisonXmlAttribute toCompareAttribute;
                toCompareAttributes.TryGetValue(attribute.Key, out toCompareAttribute);
                if (toCompareAttribute == null)
                {
                    continue;
                }

                var response = attribute.Value.AreAttributesEquivalent(toCompareAttribute);

                if (response.Equivalent)
                {
                    continue;
                }
                responses.Add(response);
            }
        }