Example #1
0
        public void TestSerializeString()
        {
            var unionType = new TestUnionType
            {
                Height = "42%",
            };
            var actual = JsonConvert.SerializeObject(unionType, Formatting.None, Settings);
            var expect = "{\"height\":\"42%\"}";

            Assert.AreEqual(expect, actual);
        }
Example #2
0
        public void TestSerializePerson()
        {
            var unionType = new TestUnionType
            {
                Height = 42,
                Person = new Person
                {
                    Name = "Alice",
                    Age  = 18,
                }
            };
            var actual = JsonConvert.SerializeObject(unionType, Formatting.None, Settings);
            var expect = "{\"height\":42,\"person\":{\"name\":\"Alice\",\"age\":18}}";

            Assert.AreEqual(expect, actual);
        }