public void GeneratedJTokenTest()
        {
            Random rndGen             = new Random(1);
            int    oldMaxArray        = CreatorSettings.MaxArrayLength;
            int    oldMaxList         = CreatorSettings.MaxListLength;
            int    oldMaxStr          = CreatorSettings.MaxStringLength;
            double oldNullProbability = CreatorSettings.NullValueProbability;
            bool   oldCreateAscii     = CreatorSettings.CreateOnlyAsciiChars;

            CreatorSettings.MaxArrayLength       = 5;
            CreatorSettings.MaxListLength        = 3;
            CreatorSettings.MaxStringLength      = 3;
            CreatorSettings.NullValueProbability = 0;
            CreatorSettings.CreateOnlyAsciiChars = true;
            JTokenCreatorSurrogate jsonValueCreator = new JTokenCreatorSurrogate();

            try
            {
                for (int i = 0; i < 1000; i++)
                {
                    JToken jv = (JToken)jsonValueCreator.CreateInstanceOf(typeof(JToken), rndGen);
                    if (jv.Type == JTokenType.Array || jv.Type == JTokenType.Object)
                    {
                        string jaStr = FormUrlEncoding(jv);
                        byte[] data  = Encoding.UTF8.GetBytes(jaStr);
                        for (var cnt = 1; cnt <= data.Length; cnt += 4)
                        {
                            ICollection <KeyValuePair <string, string> > collection;
                            FormUrlEncodedParser parser = FormUrlEncodedParserTests.CreateParser(data.Length + 1, out collection);
                            Assert.NotNull(parser);

                            int         totalBytesConsumed;
                            ParserState state = FormUrlEncodedParserTests.ParseBufferInSteps(parser, data, cnt, out totalBytesConsumed);
                            Assert.Equal(ParserState.Done, state);
                            Assert.Equal(data.Length, totalBytesConsumed);

                            JObject deserJo = FormUrlEncodedJson.Parse(collection);
                            Assert.NotNull(deserJo);
                            bool compare = true;
                            if (((IDictionary <string, JToken>)deserJo).ContainsKey("JV"))
                            {
                                compare = JTokenRoundTripComparer.Compare(jv, deserJo["JV"]);
                            }
                            else
                            {
                                compare = JTokenRoundTripComparer.Compare(jv, deserJo);
                            }

                            Assert.True(compare, "Comparison failed for test instance " + i);
                        }
                    }
                }
            }
            finally
            {
                CreatorSettings.MaxArrayLength       = oldMaxArray;
                CreatorSettings.MaxListLength        = oldMaxList;
                CreatorSettings.MaxStringLength      = oldMaxStr;
                CreatorSettings.NullValueProbability = oldNullProbability;
                CreatorSettings.CreateOnlyAsciiChars = oldCreateAscii;
            }
        }