private void AssertVisitedEquivalent(IEnumerable <ValidationResult> validationResults, IVisitableDefinition expectedDefinition)
        {
            var match   = validationResults.Any(result => result.ValidatedDefinition.FullName == expectedDefinition.FullName);
            var message = string.Format("Expected {0} '{1}' to be visited.", expectedDefinition.GetType().Name, expectedDefinition.FullName);

            Assert.That(match, message);
        }
        public void ValidationEndsFor(IVisitableDefinition definition)
        {
            ArgumentUtility.CheckNotNull("definition", definition);
            if (_currentData.Count == 0)
            {
                string message = string.Format("Validation of definition {0}/{1} cannot be ended, because it wasn't started.", definition.GetType().Name,
                                               definition.FullName);
                throw new InvalidOperationException(message);
            }
            else
            {
                ValidationResult currentResult = _currentData.Peek();
                // Only compare the full name rather than creating a new ID - it's more performant, and it's only a safety check anyway
                if (currentResult.ValidatedDefinition.FullName != definition.FullName)
                {
                    string message = string.Format(
                        "Cannot end validation for {0} while {1} is validated.",
                        definition.FullName,
                        currentResult.ValidatedDefinition.FullName);
                    throw new InvalidOperationException(message);
                }

                _currentData.Pop();
                _data.Add(currentResult);
            }
        }