public void GetAnnotations_MultipleTypes() { JObject o = new JObject(); o.AddAnnotation("A string!"); o.AddAnnotation("A string 2!"); o.AddAnnotation("A string 3!"); o.AddAnnotation(new Uri("http://www.google.com/")); IList <object> l = o.Annotations <object>().ToList(); Assert.AreEqual(4, l.Count); Assert.AreEqual("A string!", l[0]); Assert.AreEqual("A string 2!", l[1]); Assert.AreEqual("A string 3!", l[2]); Assert.AreEqual(new Uri("http://www.google.com/"), l[3]); l = o.Annotations(typeof(object)).ToList(); Assert.AreEqual(4, l.Count); Assert.AreEqual("A string!", l[0]); Assert.AreEqual("A string 2!", l[1]); Assert.AreEqual("A string 3!", l[2]); Assert.AreEqual(new Uri("http://www.google.com/"), l[3]); }
public void GetAnnotations() { JObject o = new JObject(); o.AddAnnotation("A string!"); o.AddAnnotation("A string 2!"); o.AddAnnotation("A string 3!"); IList <string> l = o.Annotations <string>().ToList(); Assert.AreEqual(3, l.Count); Assert.AreEqual("A string!", l[0]); Assert.AreEqual("A string 2!", l[1]); Assert.AreEqual("A string 3!", l[2]); l = o.Annotations(typeof(string)).Cast <string>().ToList(); Assert.AreEqual(3, l.Count); Assert.AreEqual("A string!", l[0]); Assert.AreEqual("A string 2!", l[1]); Assert.AreEqual("A string 3!", l[2]); }
public void MultipleAnnotationsAreCopied() { Version version = new Version(1, 2, 3, 4); JObject o = new JObject(); o.AddAnnotation("string!"); o.AddAnnotation(version); JObject o2 = (JObject)o.DeepClone(); Assert.AreEqual("string!", o2.Annotation <string>()); Assert.AreEqual(version, o2.Annotation <Version>()); o2.RemoveAnnotations <Version>(); Assert.AreEqual(1, o.Annotations <Version>().Count()); Assert.AreEqual(0, o2.Annotations <Version>().Count()); }