public void WriteNameValue_WithIntValue_WhenNameIsNull_Throws()
        {
            ArgumentNullException exception = Assert.Throws <ArgumentNullException>(
                () => _writer.WriteNameValue(name: null, value: 0));

            Assert.Equal("name", exception.ParamName);
        }
Esempio n. 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);
        }