Exemplo n.º 1
0
        private void CompareCompared(
            PrtgNode first,
            PrtgNode second,
            TreeNodeDifference[] filters,
            TreeNodeDifference[] normal,
            TreeNodeDifference[] filtered
            )
        {
            Assert.AreEqual(normal.Length, filtered.Length, "Differences to check against results should be the same for both normal and filtered.");

            var normalComparison = first.CompareTo(second);
            var normalNodes      = normalComparison.DescendantNodesAndSelf().ToArray();

            Assert.AreEqual(normal.Length, normalNodes.Length, "Normal differences did not match number of normal nodes.");

            for (var i = 0; i < normalNodes.Length; i++)
            {
                Assert.AreEqual(normal[i], normalNodes[i].Difference.Value, $"Difference on normal node {normalNodes[i]} did not match.");
            }

            var filteredComparison = first.CompareTo(second, filters);
            var filteredNodes      = filteredComparison.DescendantNodesAndSelf().ToArray();

            Assert.AreEqual(filtered.Length, filteredNodes.Length, "Filtered differences did not match number of filtered nodes.");

            for (var i = 0; i < filteredNodes.Length; i++)
            {
                Assert.AreEqual(filtered[i], filteredNodes[i].Difference.Value, $"Difference on filtered node {filteredNodes[i]} did not match.");
            }
        }
Exemplo n.º 2
0
        internal static void Validate(
            PrtgNode first,
            PrtgNode second,
            Validation[] validateFirst,
            Validation[] validateSecond = null,
            Action <CompareNode, CompareNode> additionalValidations = null)
        {
            if (validateSecond == null)
            {
                validateSecond = validateFirst;
            }

            var firstComparison = first.CompareTo(second);

            foreach (var comparison in validateFirst)
            {
                Assert.AreEqual(comparison.Expected, comparison.GetActual(firstComparison), "Validation of first comparison failed");
            }

            var secondComparison = second.CompareTo(first);

            foreach (var comparison in validateSecond)
            {
                Assert.AreEqual(comparison.Expected, comparison.GetActual(secondComparison), "Validation of second comparison failed");
            }

            additionalValidations?.Invoke(firstComparison, secondComparison);
        }
Exemplo n.º 3
0
        private void ValidatePretty(PrtgNode first, PrtgNode second, string[] validateFirst, string[] validateSecond = null)
        {
            if (validateSecond == null)
            {
                validateSecond = validateFirst;
            }

            var firstComparison = first.CompareTo(second);

            firstComparison.PrettyPrint(new ComparePrettyValidator(validateFirst));

            var secondComparison = second.CompareTo(first);

            secondComparison.PrettyPrint(new ComparePrettyValidator(validateSecond));
        }