public override Result Assert(HttpOperation operation)
        {
            var current = GeneratePattern(operation);

            if (_savedPattern == null)
            {
                SaveNewPattern(current);
                return(Ok);
            }

            var patterns = new JsonComparer(_savedPattern, current, _ignore);

            if (operation.TestServer.Repair && patterns.AreEquivalent == false)
            {
                SaveNewPattern(current);
                return(Ok);
            }

            if (patterns.AreEquivalent)
            {
                return(Ok);
            }

            return(Failure($"Operation is different than expected. \nVerify the differences: \n\n{patterns.GetDifferences()}"));
        }
        public override Result Assert(HttpOperation operation)
        {
            // TODO: Add non-nullable annotations to OrFail() - and other contract methods
            var current = operation.Response.Content.ReadJson().OrFail("response") !;

            if (_savedPattern == null)
            {
                SaveNewPattern(current);
                return(Ok);
            }

            JsonComparer patterns = new JsonComparer(_savedPattern, current, _ignore);

            if (patterns.AreEquivalent)
            {
                return(Ok);
            }

            switch (_mode)
            {
            case Mode.ContractCheck:
                // Always save new response (contract) when running in contract-check-mode
                SaveNewPattern(current);
                break;

            case Mode.Default:
                if (operation.TestServer.Repair)
                {
                    SaveNewPattern(current);
                    return(Ok);
                }

                break;

            default:
                throw Fail.BecauseEnumOutOfRange(_mode);
            }

            return(Failure($"Response is different than expected. \nVerify the differences: \n\n{patterns.GetDifferences()}"));
        }