public void IncludeInheritedProps()
 {
     MockContract discretional = new MockContract();
     OptionalContractResolver resolver = new OptionalContractResolver();
     resolver.Add(typeof(MockContract), "Fred");
     string json = JsonConvert.SerializeObject(discretional, new JsonSerializerSettings { ContractResolver = resolver });
     Assert.IsTrue(json.Contains("Fred"));
 }
 public void DefaultEmpty()
 {
     MockContract discretional = new MockContract();
     OptionalContractResolver resolver = new OptionalContractResolver();
     resolver.Add(typeof(MockContract));
     string json = JsonConvert.SerializeObject(discretional, new JsonSerializerSettings { ContractResolver = resolver });
     Assert.AreEqual("{}", json);
 }
 public void DoNotIncludePropsByDefault()
 {
     MockContract discretional = new MockContract();
     OptionalContractResolver resolver = new OptionalContractResolver();
     resolver.Add(typeof(MockContract), "Qux");
     string json = JsonConvert.SerializeObject(discretional, new JsonSerializerSettings { ContractResolver = resolver });
     Assert.IsFalse(json.Contains("Foo"));
 }
 public void AlwaysIncludeRequestedFields()
 {
     MockContract discretional = new MockContract();
     OptionalContractResolver resolver = new OptionalContractResolver();
     resolver.Add(typeof(MockContract), "Qux");
     string json = JsonConvert.SerializeObject(discretional, new JsonSerializerSettings { ContractResolver = resolver });
     Assert.IsTrue(json.Contains("Qux"));
 }
 public void IncludeSubTypeProps()
 {
     MockContract discretional = new MockContract
                                 { SubType = new MockContractSub() };
     OptionalContractResolver resolver = new OptionalContractResolver();
     resolver.Add(typeof(MockContract), "SubType");
     string json = JsonConvert.SerializeObject(discretional, new JsonSerializerSettings { ContractResolver = resolver });
     Assert.IsTrue(json.Contains("Corge"));
 }