public void ReferencedComponentList() { var c1 = new TestComponentSimple(); ReferencedList <TestComponentSimple> l = new ReferencedList <TestComponentSimple>(); l.Add(c1); l.Add(new TestComponentSimple()); l.Add(c1); string json = JsonConvert.SerializeObject(l, Formatting.Indented); StringAssert.AreEqual(@"[ { ""$id"": ""1"", ""MyProperty"": 0 }, { ""$id"": ""2"", ""MyProperty"": 0 }, { ""$ref"": ""1"" } ]", json); }
public void ReferencedIntList() { ReferencedList <int> l = new ReferencedList <int>(); l.Add(1); l.Add(2); l.Add(3); string json = JsonConvert.SerializeObject(l, Formatting.Indented); StringAssert.AreEqual(@"[ 1, 2, 3 ]", json); }