public void WriteNameArray_WhenNameIsNull_Throws()
        {
            ArgumentNullException exception = Assert.Throws <ArgumentNullException>(
                () => _writer.WriteNameArray(name: null, values: new[] { "b", "c" }));

            Assert.Equal("name", exception.ParamName);
        }
Exemple #2
0
        public void GetJson()
        {
            _writer.WriteNameValue("a", 1);
            _writer.WriteNameValue("B", "C");
            _writer.WriteNameArray("d", new[] { "e", "f" });

            _writer.WriteObjectStart("g");
            _writer.WriteNameValue("h", "i");
            _writer.WriteObjectEnd();

            const string expectedJson = @"{
  ""a"": 1,
  ""B"": ""C"",
  ""d"": [
    ""e"",
    ""f""
  ],
  ""g"": {
    ""h"": ""i""
  }
}";
            var          actualJson   = _writer.GetJson();

            Assert.Equal(expectedJson, actualJson);
        }