public void TestToJson_ComplexObject() { var input = new ComplexObject { ParentId = 456, ChildObject = new TestObject { IntProperty = 123, StringProperty = "Some String" } }; var output = input.ToJson(); Assert.AreEqual(output, "{\"ParentId\":456,\"ChildObject\":{\"IntProperty\":123,\"StringProperty\":\"Some String\"}}"); }
public void TestToJson_ComplexObjectWithNullChild() { var input = new ComplexObject { ParentId = 456, ChildObject = null }; var output = input.ToJson(); Assert.AreEqual(output, "{\"ParentId\":456,\"ChildObject\":null}"); }