public void ComplexType_WithAllNullPropertiesTest() { Customer customer = new Customer(); string json = JsonConverter.SerializeObject(customer); Assert.AreEqual("{}", json); }
public void ComplexType_ShouldIgnoreNullPropertiesTest() { Customer customer = new Customer(); customer.FirstName = "Bob"; string json = JsonConverter.SerializeObject(customer); Assert.AreEqual("{firstName:'Bob'}", json); }
public void ComplexType_ShouldIgnoreComplexPropertyWhenAllOfItsPropertiesAreNull() { Customer customer = new Customer(); customer.FirstName = "Bob"; customer.Friend = new Customer(); string json = JsonConverter.SerializeObject(customer); Assert.AreEqual("{firstName:'Bob'}", json); }
public void ComplexTypeTest() { Customer customer = new Customer(); customer.FirstName = "Bob"; customer.LastName = "Marley"; customer.Age = 35; customer.Type = CustomerType.Special; customer.Ids = new int[] { 10, 20, 30 }; string json = JsonConverter.SerializeObject(customer); Assert.AreEqual("{firstName:'Bob',lastName:'Marley',age:35,type:'special',ids:[10,20,30]}", json); }
public void ComplexType_WithComplexPropertyTest() { Customer customer = new Customer(); customer.FirstName = "Bob"; customer.Friend = new Customer(); customer.Friend.FirstName = "Doug"; string json = JsonConverter.SerializeObject(customer); Assert.AreEqual("{firstName:'Bob',friend:{firstName:'Doug'}}", json); }