public void WriteTo () { var doc = new InlineCategoriesDocument (); var f = new AtomPub10CategoriesDocumentFormatter (doc); doc.Scheme = "http"; doc.IsFixed = false; var sw = new StringWriter (); using (var xw = XmlWriter.Create (sw, settings)) f.WriteTo (xw); Assert.AreEqual (app1, sw.ToString ()); }
public static CategoriesDocument Load (XmlReader reader) { if (reader == null) throw new ArgumentNullException ("reader"); var f = new AtomPub10CategoriesDocumentFormatter (); reader.MoveToContent (); CategoriesDocument doc; if (reader.GetAttribute ("href") == null) doc = new InlineCategoriesDocument (); else doc = new ReferencedCategoriesDocument (); doc.GetFormatter ().ReadFrom (reader); return doc; }
public override void WriteToStream(Type type, object value, Stream writeStream, HttpContent content) { var document = value as IPublicationCategoriesDocument; var atomDoc = new InlineCategoriesDocument( document.Categories.Select(c => new SyndicationCategory(c.Name) { Label = c.Label }), document.IsFixed, document.Scheme ); var formatter = new AtomPub10CategoriesDocumentFormatter(atomDoc); using (writeStream) { using (var writer = XmlWriter.Create(writeStream)) { formatter.WriteTo(writer); } } }
public static CategoriesDocument Load(XmlReader reader) { AtomPub10CategoriesDocumentFormatter formatter = new AtomPub10CategoriesDocumentFormatter(); formatter.ReadFrom(reader); return formatter.Document; }
public void ReadFrom () { var f = new AtomPub10CategoriesDocumentFormatter (); f.ReadFrom (XmlReader.Create (new StringReader (app1))); var inline = f.Document as InlineCategoriesDocument; Assert.IsNotNull (inline, "#1"); Assert.AreEqual ("http", inline.Scheme, "#2"); }
public void WriteTo2 () { var doc = new InlineCategoriesDocument (); var f = new AtomPub10CategoriesDocumentFormatter (doc); doc.Categories.Add (new SyndicationCategory ("TEST CATEGORY")); var sw = new StringWriter (); using (var xw = XmlWriter.Create (sw, settings)) f.WriteTo (xw); Assert.AreEqual (app2, sw.ToString ()); }
public void GetSchema () { IXmlSerializable i = new AtomPub10CategoriesDocumentFormatter (); Assert.IsNull (i.GetSchema ()); }