public IEnumerable <IJsonCompareError <JToken> > Compare(JToken expected, JToken actual, string path)
        {
            var(captureSucceeded, captureErrors) = _jsonSpecialHandler.HandleSpecialObject(expected, actual, path, this);
            if (captureSucceeded)
            {
                yield break;
            }
            if (captureErrors?.Count > 0)
            {
                foreach (var error in captureErrors)
                {
                    yield return(error);
                }
                yield break;
            }

            if (expected.Type != actual.Type)
            {
                yield return(new InvalidTypeJsonCompareError(path, expected, actual));

                yield break;
            }

            IEnumerable <IJsonCompareError <JToken> > errors;

            switch (actual.Type)
            {
            case JTokenType.Object:
                errors = _jsonObjectComparer.Compare(expected as JObject, actual as JObject, this, path);
                break;

            case JTokenType.Array:
                errors = _jsonArrayComparer.Compare(expected as JArray, actual as JArray, this, path);
                break;

            case JTokenType.Integer:
            case JTokenType.Float:
            case JTokenType.String:
            case JTokenType.Boolean:
            case JTokenType.Null:
            case JTokenType.Undefined:
            case JTokenType.Date:
                errors = _jsonValueComparer.Compare(expected as JValue, actual as JValue, path);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(actual.Type), actual.Type, "Cannot compare this type");
            }

            foreach (var jsonCompareError in errors)
            {
                yield return(jsonCompareError);
            }
        }
        public void WhenComparingArrays_UseJsonArrayComparer()
        {
            var expectedJson = JArray.Parse("[]");
            var actualJson   = JArray.Parse("[]");

            _jsonArrayComparer.Compare(expectedJson, actualJson, _jsonComparer)
            .Returns(new List <JsonCompareError> {
                new TestJsonCompareError()
            });

            var actualErrors = _jsonComparer.Compare(expectedJson, actualJson);

            using (new AssertionScope())
            {
                actualErrors.Should().NotBeNullOrEmpty();
                actualErrors.First().Should().BeOfType <TestJsonCompareError>();
            }
        }