Beispiel #1
0
        public void WriteJsonGeneric()
        {
            StringWriter   sw         = new StringWriter();
            JsonTextWriter jsonWriter = new JsonTextWriter(sw);

            TestGenericConverter converter = new TestGenericConverter();

            converter.WriteJson(jsonWriter, "String!", null);

            Assert.AreEqual(@"""String!""", sw.ToString());
        }
Beispiel #2
0
        public void WriteJsonBadType()
        {
            StringWriter   sw         = new StringWriter();
            JsonTextWriter jsonWriter = new JsonTextWriter(sw);

            TestGenericConverter converter = new TestGenericConverter();

            ExceptionAssert.Throws <JsonSerializationException>(() =>
            {
                converter.WriteJson(jsonWriter, 123, null);
            }, "Converter cannot write specified value to JSON. System.String is required.");
        }