public void ReferencedComponentDictionary()
        {
            var c1 = new TestComponentSimple();

            ReferencedDictionary <TestComponentSimple> l = new ReferencedDictionary <TestComponentSimple>();

            l.Add("First", c1);
            l.Add("Second", new TestComponentSimple());
            l.Add("Third", c1);

            string json = JsonConvert.SerializeObject(l, Formatting.Indented);

            StringAssert.AreEqual(@"{
  ""First"": {
    ""$id"": ""1"",
    ""MyProperty"": 0
  },
  ""Second"": {
    ""$id"": ""2"",
    ""MyProperty"": 0
  },
  ""Third"": {
    ""$ref"": ""1""
  }
}", json);

            ReferencedDictionary <TestComponentSimple> d = JsonConvert.DeserializeObject <ReferencedDictionary <TestComponentSimple> >(json);

            Assert.AreEqual(3, d.Count);
            Assert.IsTrue(ReferenceEquals(d["First"], d["Third"]));
        }
        public void ReferencedIntDictionary()
        {
            ReferencedDictionary <int> l = new ReferencedDictionary <int>();

            l.Add("First", 1);
            l.Add("Second", 2);
            l.Add("Third", 3);

            string json = JsonConvert.SerializeObject(l, Formatting.Indented);

            StringAssert.AreEqual(@"{
  ""First"": 1,
  ""Second"": 2,
  ""Third"": 3
}", json);
        }