public void CreateSetWithBadObjectTarget()
    {
      Person p = new Person();
      Movie m = new Movie();

      Action<object, object> setter = DynamicReflectionDelegateFactory.Instance.CreateSet<object>(typeof(Movie).GetProperty("Name"));

      setter(m, "Hi");

      Assert.AreEqual(m.Name, "Hi");

      setter(p, "Hi");
    }
    public void NullValueHandlingBlogPost()
    {
      Movie movie = new Movie();
      movie.Name = "Bad Boys III";
      movie.Description = "It's no Bad Boys";

      string included = JsonConvert.SerializeObject(movie,
        Formatting.Indented,
        new JsonSerializerSettings { });

      // {
      //   "Name": "Bad Boys III",
      //   "Description": "It's no Bad Boys",
      //   "Classification": null,
      //   "Studio": null,
      //   "ReleaseDate": null,
      //   "ReleaseCountries": null
      // }

      string ignored = JsonConvert.SerializeObject(movie,
        Formatting.Indented,
        new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });

      // {
      //   "Name": "Bad Boys III",
      //   "Description": "It's no Bad Boys"
      // }

      Assert.AreEqual(@"{
  ""Name"": ""Bad Boys III"",
  ""Description"": ""It's no Bad Boys"",
  ""Classification"": null,
  ""Studio"": null,
  ""ReleaseDate"": null,
  ""ReleaseCountries"": null
}", included);

      Assert.AreEqual(@"{
  ""Name"": ""Bad Boys III"",
  ""Description"": ""It's no Bad Boys""
}", ignored);
    }
    public void CreateSetWithBadObjectValue()
    {
      Movie m = new Movie();

      Action<object, object> setter = DynamicReflectionDelegateFactory.Instance.CreateSet<object>(typeof(Movie).GetProperty("Name"));

      setter(m, new Version());
    }