private void Check(ComparisonType comparisonType, object target, bool indented) { var tinyJsonSerializer = CreateTinyJsonSerializer(indented); var actualJson = tinyJsonSerializer(target); switch (comparisonType) { case ExactMatch _: { var referenceSerializer = CreateReferenceSerializer(indented); var referenceJson = referenceSerializer(target); Console.WriteLine($"Reference value: '{referenceJson}'"); Console.WriteLine($"Our value: '{actualJson}'"); Assert.That(actualJson, Is.EqualTo(referenceJson)); } break; case DeepComparison _: { var referenceSerializer = CreateReferenceSerializer(indented); var referenceJson = referenceSerializer(target); Console.WriteLine($"Reference value: '{referenceJson}'"); Console.WriteLine($"Our value: '{actualJson}'"); var referenceJToken = JToken.Parse(referenceJson); var actualJToken = JToken.Parse(actualJson); Assert.That( actualJToken, Is.EqualTo(referenceJToken).Using((JToken a, JToken b) => JToken.DeepEquals(a, b) ? 0 : 1)); } break; case RegexMatch match: { Console.WriteLine($"Reference regex: '{match.Pattern}'"); Console.WriteLine($"Our value: '{actualJson}'"); Assert.That(actualJson, Does.Match(match.Pattern)); } break; default: Assert.Fail($"Unhandled comparison type {comparisonType.GetType().FullName}"); break; } }