public void FloatingPointNonFiniteNumbers_QuoteChar()
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);

            using (JsonTextWriter jsonWriter = new JsonTextWriter(sw))
            {
                jsonWriter.Formatting = Formatting.Indented;
                jsonWriter.FloatFormatHandling = FloatFormatHandling.String;
                jsonWriter.QuoteChar = '\'';

                jsonWriter.WriteStartArray();
                jsonWriter.WriteValue(double.NaN);
                jsonWriter.WriteValue(double.PositiveInfinity);
                jsonWriter.WriteValue(double.NegativeInfinity);
                jsonWriter.WriteValue(float.NaN);
                jsonWriter.WriteValue(float.PositiveInfinity);
                jsonWriter.WriteValue(float.NegativeInfinity);
                jsonWriter.WriteEndArray();

                jsonWriter.Flush();
            }

            string expected = @"[
  'NaN',
  'Infinity',
  '-Infinity',
  'NaN',
  'Infinity',
  '-Infinity'
]";
            string result = sb.ToString();

            StringAssert.Equal(expected, result);
        }
        public void QuoteNameAndStrings()
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            JsonTextWriter writer = new JsonTextWriter(sw) { QuoteName = false };

            writer.WriteStartObject();

            writer.WritePropertyName("name");
            writer.WriteValue("value");

            writer.WriteEndObject();
            writer.Flush();

            Assert.Equal(@"{name:""value""}", sb.ToString());
        }
        public void FloatingPointNonFiniteNumbers_Zero()
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);

            using (JsonWriter jsonWriter = new JsonTextWriter(sw))
            {
                jsonWriter.Formatting = Formatting.Indented;
                jsonWriter.FloatFormatHandling = FloatFormatHandling.DefaultValue;

                jsonWriter.WriteStartArray();
                jsonWriter.WriteValue(double.NaN);
                jsonWriter.WriteValue(double.PositiveInfinity);
                jsonWriter.WriteValue(double.NegativeInfinity);
                jsonWriter.WriteValue(float.NaN);
                jsonWriter.WriteValue(float.PositiveInfinity);
                jsonWriter.WriteValue(float.NegativeInfinity);
                jsonWriter.WriteValue((double?)double.NaN);
                jsonWriter.WriteValue((double?)double.PositiveInfinity);
                jsonWriter.WriteValue((double?)double.NegativeInfinity);
                jsonWriter.WriteValue((float?)float.NaN);
                jsonWriter.WriteValue((float?)float.PositiveInfinity);
                jsonWriter.WriteValue((float?)float.NegativeInfinity);
                jsonWriter.WriteEndArray();

                jsonWriter.Flush();
            }

            string expected = @"[
  0.0,
  0.0,
  0.0,
  0.0,
  0.0,
  0.0,
  null,
  null,
  null,
  null,
  null,
  null
]";
            string result = sb.ToString();

            StringAssert.Equal(expected, result);
        }