Author: atsushi
Date: 2007-12-15 06:25:08 -0500 (Sat, 15 Dec 2007)
New Revision: 91350

Added:
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/SyndicationElementExtensionTest.cs
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/TextSyndicationContentTest.cs
Modified:
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/Rss20ItemFormatter.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationCategory.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationElementExtension.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationExtensions.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationFeed.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationItem.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationItemFormatter.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationLink.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationPerson.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/ChangeLog
Log:
2007-12-15  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * SyndicationFeed.cs : do not try to set null items in .ctor() (null
          items are allowed in .ctor, while not allowed in set_Items()).
          Remove extra NotImplementedException.
          Implemented WriteAttributeExtensions and WriteElementExtensions.
        * SyndicationElementExtension.cs : implemented.
        * SyndicationExtensions.cs,
          SyndicationItem.cs, SyndicationLink.cs, SyndicationCategory.cs,
          SyndicationPerson.cs : Implemented WriteAttributeExtensions() and
          WriteElementExtensions() in each syndication element to call 
          corresponding method in SyndicationExtensions.
        * SyndicationItemFormatter.cs :
          implemented Write[Element/Attribute]Extensions() and
          TryParse[Element/Attribute]().
        * Rss20ItemFormatter.cs : write extensions on writing to xml.
          Null check in Contributors on writing to xml.

        * SyndicationElementExtensionTest.cs : new test.
        * TextSyndicationContentTest.cs : was missing in the previous commit.



Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog
 2007-12-15 05:11:27 UTC (rev 91349)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog
 2007-12-15 11:25:08 UTC (rev 91350)
@@ -1,3 +1,21 @@
+2007-12-15  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * SyndicationFeed.cs : do not try to set null items in .ctor() (null
+         items are allowed in .ctor, while not allowed in set_Items()).
+         Remove extra NotImplementedException.
+         Implemented WriteAttributeExtensions and WriteElementExtensions.
+       * SyndicationElementExtension.cs : implemented.
+       * SyndicationExtensions.cs,
+         SyndicationItem.cs, SyndicationLink.cs, SyndicationCategory.cs,
+         SyndicationPerson.cs : Implemented WriteAttributeExtensions() and
+         WriteElementExtensions() in each syndication element to call 
+         corresponding method in SyndicationExtensions.
+       * SyndicationItemFormatter.cs :
+         implemented Write[Element/Attribute]Extensions() and
+         TryParse[Element/Attribute]().
+       * Rss20ItemFormatter.cs : write extensions on writing to xml.
+         Null check in Contributors on writing to xml.
+
 2007-12-11  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * Rss20ItemFormatter.cs, SyndicationContent.cs,

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/Rss20ItemFormatter.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/Rss20ItemFormatter.cs
     2007-12-15 05:11:27 UTC (rev 91349)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/Rss20ItemFormatter.cs
     2007-12-15 11:25:08 UTC (rev 91350)
@@ -109,7 +109,6 @@
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO]
                public override void WriteTo (XmlWriter writer)
                {
                        WriteXml (writer, true);
@@ -121,7 +120,6 @@
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO]
                void IXmlSerializable.WriteXml (XmlWriter writer)
                {
                        WriteXml (writer, false);
@@ -133,7 +131,7 @@
                        throw new NotImplementedException ();
                }
 
-               // FIXME: call WriteElementExtensions() and 
WriteAttributExtensions on every syndication element.
+               // FIXME: output every non-ISyndicationElement properties (id, 
pubDate, etc.)
                void WriteXml (XmlWriter writer, bool writeRoot)
                {
                        if (writer == null)
@@ -153,7 +151,9 @@
                        foreach (SyndicationPerson author in Item.Authors)
                                if (author != null) {
                                        writer.WriteStartElement ("author");
+                                       WriteAttributeExtensions (writer, 
author, Version);
                                        writer.WriteString (author.Email);
+                                       WriteElementExtensions (writer, author, 
Version);
                                        writer.WriteEndElement ();
                                }
                        foreach (SyndicationCategory category in 
Item.Categories)
@@ -161,7 +161,9 @@
                                        writer.WriteStartElement ("category");
                                        if (category.Scheme != null)
                                                writer.WriteAttributeString 
("domain", category.Scheme);
+                                       WriteAttributeExtensions (writer, 
category, Version);
                                        writer.WriteString (category.Name);
+                                       WriteElementExtensions (writer, 
category, Version);
                                        writer.WriteEndElement ();
                                }
                        if (Item.Summary != null)
@@ -174,18 +176,24 @@
                        foreach (SyndicationLink link in Item.Links)
                                if (link != null) {
                                        writer.WriteStartElement ("link");
+                                       WriteAttributeExtensions (writer, link, 
Version);
                                        writer.WriteString (link.Uri != null ? 
link.Uri.ToString () : String.Empty);
+                                       WriteElementExtensions (writer, link, 
Version);
                                        writer.WriteEndElement ();
                                }
 
                        // Contributors are part of Atom extension
                        if (SerializeExtensionsAsAtom)
                                foreach (SyndicationPerson contributor in 
Item.Contributors) {
-                                       writer.WriteStartElement 
("contributor", AtomNamespace);
-                                       writer.WriteElementString ("name", 
AtomNamespace, contributor.Name);
-                                       writer.WriteElementString ("uri", 
AtomNamespace, contributor.Uri);
-                                       writer.WriteElementString ("email", 
AtomNamespace, contributor.Email);
-                                       writer.WriteEndElement ();
+                                       if (contributor != null) {
+                                               writer.WriteStartElement 
("contributor", AtomNamespace);
+                                               WriteAttributeExtensions 
(writer, contributor, Version);
+                                               writer.WriteElementString 
("name", AtomNamespace, contributor.Name);
+                                               writer.WriteElementString 
("uri", AtomNamespace, contributor.Uri);
+                                               writer.WriteElementString 
("email", AtomNamespace, contributor.Email);
+                                               WriteElementExtensions (writer, 
contributor, Version);
+                                               writer.WriteEndElement ();
+                                       }
                                }
 
                        if (writeRoot)

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationCategory.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationCategory.cs
    2007-12-15 05:11:27 UTC (rev 91349)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationCategory.cs
    2007-12-15 11:25:08 UTC (rev 91350)
@@ -106,17 +106,14 @@
                        throw new NotImplementedException ();
                }
 
-
-               [MonoTODO]
                protected internal virtual void WriteAttributeExtensions 
(XmlWriter writer, string version)
                {
-                       throw new NotImplementedException ();
+                       extensions.WriteAttributeExtensions (writer, version);
                }
 
-               [MonoTODO]
                protected internal virtual void WriteElementExtensions 
(XmlWriter writer, string version)
                {
-                       throw new NotImplementedException ();
+                       extensions.WriteElementExtensions (writer, version);
                }
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationElementExtension.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationElementExtension.cs
    2007-12-15 05:11:27 UTC (rev 91349)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationElementExtension.cs
    2007-12-15 11:25:08 UTC (rev 91350)
@@ -38,80 +38,184 @@
 {
        public class SyndicationElementExtension
        {
-               [MonoTODO]
+               ReadWriteHandler handler;
+
                public SyndicationElementExtension (object 
dataContractExtension)
+                       : this (dataContractExtension, (XmlObjectSerializer) 
null)
                {
-                       throw new NotImplementedException ();
                }
 
-               [MonoTODO]
                public SyndicationElementExtension (object 
dataContractExtension, XmlObjectSerializer dataContractSerializer)
+                       : this (null, null, dataContractExtension, 
dataContractSerializer)
                {
-                       throw new NotImplementedException ();
                }
 
-               [MonoTODO]
-               public SyndicationElementExtension (object 
xmlSerializerExtension, XmlSerializer serializer)
+               public SyndicationElementExtension (string outerName, string 
outerNamespace, object dataContractExtension)
+                       : this (outerName, outerNamespace, 
dataContractExtension, null)
                {
-                       throw new NotImplementedException ();
                }
 
-               [MonoTODO]
-               public SyndicationElementExtension (string outerName, string 
outerNamespace, object dataContractExtension)
+               public SyndicationElementExtension (string outerName, string 
outerNamespace, object dataContractExtension, XmlObjectSerializer 
dataContractSerializer)
                {
-                       throw new NotImplementedException ();
+                       if (dataContractExtension == null)
+                               throw new ArgumentNullException 
("dataContractExtension");
+                       handler = new DataContractReadWriteHandler (outerName, 
outerNamespace, dataContractExtension, dataContractSerializer);
                }
 
-               [MonoTODO]
-               public SyndicationElementExtension (string outerName, string 
outerNamespace, object dataContractExtension, XmlObjectSerializer 
dataContractSerializer)
+               public SyndicationElementExtension (object 
xmlSerializerExtension, XmlSerializer serializer)
                {
-                       throw new NotImplementedException ();
+                       if (xmlSerializerExtension == null)
+                               throw new ArgumentNullException 
("xmlSerializerExtension");
+                       handler = new XmlSerializationReadWriteHandler 
(xmlSerializerExtension, serializer);
                }
 
-               [MonoTODO]
                public SyndicationElementExtension (XmlReader xmlReader)
                {
-                       throw new NotImplementedException ();
+                       if (xmlReader == null)
+                               throw new ArgumentNullException ("xmlReader");
+                       xmlReader.MoveToContent ();
+                       if (xmlReader.NodeType != XmlNodeType.Element)
+                               throw new XmlException ("Element node is 
expected on the argument xmlReader");
+
+                       handler = new XmlReaderReadWriteHandler (xmlReader);
                }
 
-               [MonoTODO]
                public string OuterName {
-                       get { throw new NotImplementedException (); }
+                       get { return handler != null ? handler.Name : null; }
                }
 
-               [MonoTODO]
                public string OuterNamespace {
-                       get { throw new NotImplementedException (); }
+                       get { return handler != null ? handler.Namespace : 
null; }
                }
 
-               [MonoTODO]
                public TExtension GetObject<TExtension> ()
                {
-                       throw new NotImplementedException ();
+                       return GetObject<TExtension> (new 
DataContractSerializer (typeof (TExtension)));
                }
 
-               [MonoTODO]
                public TExtension GetObject<TExtension> (XmlObjectSerializer 
serializer)
                {
-                       throw new NotImplementedException ();
+                       if (serializer == null)
+                               throw new ArgumentNullException ("serializer");
+                       return (TExtension) serializer.ReadObject (GetReader 
());
                }
 
-               [MonoTODO]
                public TExtension GetObject<TExtension> (XmlSerializer 
serializer)
                {
-                       throw new NotImplementedException ();
+                       if (serializer == null)
+                               throw new ArgumentNullException ("serializer");
+                       return (TExtension) serializer.Deserialize (GetReader 
());
                }
 
-               [MonoTODO]
                public XmlReader GetReader ()
                {
-                       throw new NotImplementedException ();
+                       return handler.GetReader ();
                }
 
-               [MonoTODO]
                public void WriteTo (XmlWriter writer)
                {
-                       throw new NotImplementedException ();
+                       if (writer == null)
+                               throw new ArgumentNullException ("writer");
+
+                       handler.WriteTo (writer);
                }
+
+               abstract class ReadWriteHandler
+               {
+                       public virtual string Name {
+                               get { return null; }
+                       }
+
+                       public virtual string Namespace {
+                               get { return null; }
+                       }
+
+                       public virtual XmlReader GetReader ()
+                       {
+                               StringWriter sw = new StringWriter ();
+                               using (XmlWriter w = XmlWriter.Create (sw))
+                                       WriteTo (w);
+                               return XmlReader.Create (new StringReader 
(sw.ToString ()));
+                       }
+
+                       public abstract void WriteTo (XmlWriter writer);
+               }
+
+               class DataContractReadWriteHandler : ReadWriteHandler
+               {
+                       string name, ns;
+                       object extension;
+                       XmlObjectSerializer serializer;
+                       
+                       public DataContractReadWriteHandler (string name, 
string ns, object extension, XmlObjectSerializer serializer)
+                       {
+                               this.name = name;
+                               this.ns = ns;
+                               this.extension = extension;
+                               this.serializer = serializer;
+
+                               if (this.serializer == null)
+                                       this.serializer = new 
DataContractSerializer (extension.GetType ());
+                       }
+
+                       public override string Name {
+                               get { return name; }
+                       }
+
+                       public override string Namespace {
+                               get { return ns; }
+                       }
+
+                       public override void WriteTo (XmlWriter writer)
+                       {
+                               if (name != null) {
+                                       writer.WriteStartElement (name, ns);
+                                       serializer.WriteObjectContent (writer, 
extension);
+                                       writer.WriteFullEndElement ();
+                               }
+                               else
+                                       serializer.WriteObject (writer, 
extension);
+                       }
+               }
+
+               class XmlSerializationReadWriteHandler : ReadWriteHandler
+               {
+                       object extension;
+                       XmlSerializer serializer;
+
+                       public XmlSerializationReadWriteHandler (object 
extension, XmlSerializer serializer)
+                       {
+                               this.extension = extension;
+                               this.serializer = serializer;
+
+                               if (serializer == null)
+                                       serializer = new XmlSerializer 
(extension.GetType ());
+                       }
+
+                       public override void WriteTo (XmlWriter writer)
+                       {
+                               serializer.Serialize (writer, extension);
+                       }
+               }
+
+               class XmlReaderReadWriteHandler : ReadWriteHandler
+               {
+                       XmlDocument doc = new XmlDocument ();
+
+                       public XmlReaderReadWriteHandler (XmlReader reader)
+                       {
+                               doc.AppendChild (doc.ReadNode (reader));
+                       }
+
+                       public override XmlReader GetReader ()
+                       {
+                               return new XmlNodeReader (doc.FirstChild);
+                       }
+
+                       public override void WriteTo (XmlWriter writer)
+                       {
+                               doc.FirstChild.WriteTo (writer);
+                       }
+               }
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationExtensions.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationExtensions.cs
  2007-12-15 05:11:27 UTC (rev 91349)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationExtensions.cs
  2007-12-15 11:25:08 UTC (rev 91350)
@@ -64,6 +64,25 @@
                        ret.elements = elements == null ? null : new 
SyndicationElementExtensionCollection (elements);
                        return ret;
                }
+
+               internal void WriteAttributeExtensions (XmlWriter writer, 
string version)
+               {
+                       if (attributes == null)
+                               return;
+
+                       foreach (KeyValuePair<XmlQualifiedName,string> pair in 
attributes)
+                               writer.WriteAttributeString (pair.Key.Name, 
pair.Key.Namespace, pair.Value);
+               }
+
+               internal void WriteElementExtensions (XmlWriter writer, string 
version)
+               {
+                       if (elements == null)
+                               return;
+
+                       foreach (SyndicationElementExtension el in elements)
+                               if (el != null)
+                                       el.WriteTo (writer);
+               }
        }
 }
 

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationFeed.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationFeed.cs
        2007-12-15 05:11:27 UTC (rev 91349)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationFeed.cs
        2007-12-15 11:25:08 UTC (rev 91350)
@@ -57,7 +57,8 @@
 
                public SyndicationFeed (IEnumerable<SyndicationItem> items)
                {
-                       Items = items;
+                       if (items != null)
+                               Items = items;
                }
 
                public SyndicationFeed (string title, string description, Uri 
feedAlternateLink)
@@ -69,7 +70,6 @@
                                        IEnumerable<SyndicationItem> items)
                        : this (title, description, feedAlternateLink, null, 
default (DateTimeOffset), items)
                {
-                       throw new NotImplementedException ();
                }
 
                public SyndicationFeed (string title, string description, Uri 
feedAlternateLink, string id,
@@ -87,7 +87,8 @@
                                Links.Add (SyndicationLink.CreateAlternateLink 
(feedAlternateLink));
                        Id = id;
                        LastUpdatedTime = lastUpdatedTime;
-                       Items = items;
+                       if (items != null)
+                               Items = items;
                }
 
                protected SyndicationFeed (SyndicationFeed source, bool 
cloneItems)
@@ -284,17 +285,14 @@
                        throw new NotImplementedException ();
                }
 
-
-               [MonoTODO]
                protected internal virtual void WriteAttributeExtensions 
(XmlWriter writer, string version)
                {
-                       throw new NotImplementedException ();
+                       extensions.WriteAttributeExtensions (writer, version);
                }
 
-               [MonoTODO]
                protected internal virtual void WriteElementExtensions 
(XmlWriter writer, string version)
                {
-                       throw new NotImplementedException ();
+                       extensions.WriteElementExtensions (writer, version);
                }
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationItem.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationItem.cs
        2007-12-15 05:11:27 UTC (rev 91349)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationItem.cs
        2007-12-15 11:25:08 UTC (rev 91350)
@@ -286,17 +286,14 @@
                        throw new NotImplementedException ();
                }
 
-
-               [MonoTODO]
                protected internal virtual void WriteAttributeExtensions 
(XmlWriter writer, string version)
                {
-                       throw new NotImplementedException ();
+                       extensions.WriteAttributeExtensions (writer, version);
                }
 
-               [MonoTODO]
                protected internal virtual void WriteElementExtensions 
(XmlWriter writer, string version)
                {
-                       throw new NotImplementedException ();
+                       extensions.WriteElementExtensions (writer, version);
                }
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationItemFormatter.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationItemFormatter.cs
       2007-12-15 05:11:27 UTC (rev 91349)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationItemFormatter.cs
       2007-12-15 11:25:08 UTC (rev 91350)
@@ -82,106 +82,95 @@
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO]
+               // My assumption is that those static methods are defined to
+               // be used in the derived classes and to dispatch the actual
+               // processing to each syndication element. Considering that
+               // they can be overriden in each element, I assume that these
+               // methods depend on the elements, not in reverse order.
+
                protected internal static bool TryParseAttribute (string name, 
string ns, string value, SyndicationCategory category, string version)
                {
-                       throw new NotImplementedException ();
+                       return category.TryParseAttribute (name, ns, value, 
version);
                }
 
-               [MonoTODO]
                protected internal static bool TryParseAttribute (string name, 
string ns, string value, SyndicationItem item, string version)
                {
-                       throw new NotImplementedException ();
+                       return item.TryParseAttribute (name, ns, value, 
version);
                }
 
-               [MonoTODO]
                protected internal static bool TryParseAttribute (string name, 
string ns, string value, SyndicationLink link, string version)
                {
-                       throw new NotImplementedException ();
+                       return link.TryParseAttribute (name, ns, value, 
version);
                }
 
-               [MonoTODO]
                protected internal static bool TryParseAttribute (string name, 
string ns, string value, SyndicationPerson person, string version)
                {
-                       throw new NotImplementedException ();
+                       return person.TryParseAttribute (name, ns, value, 
version);
                }
 
-               [MonoTODO]
                protected internal static bool TryParseContent (XmlReader 
reader, SyndicationItem item, string contentType, string version, out 
SyndicationContent content)
                {
-                       throw new NotImplementedException ();
+                       return item.TryParseContent (reader, contentType, 
version, out content);
                }
 
-               [MonoTODO]
                protected internal static bool TryParseElement (XmlReader 
reader, SyndicationCategory category, string version)
                {
-                       throw new NotImplementedException ();
+                       return category.TryParseElement (reader, version);
                }
 
-               [MonoTODO]
                protected internal static bool TryParseElement (XmlReader 
reader, SyndicationItem item, string version)
                {
-                       throw new NotImplementedException ();
+                       return item.TryParseElement (reader, version);
                }
 
-               [MonoTODO]
                protected internal static bool TryParseElement (XmlReader 
reader, SyndicationLink link, string version)
                {
-                       throw new NotImplementedException ();
+                       return link.TryParseElement (reader, version);
                }
 
-               [MonoTODO]
                protected internal static bool TryParseElement (XmlReader 
reader, SyndicationPerson person, string version)
                {
-                       throw new NotImplementedException ();
+                       return person.TryParseElement (reader, version);
                }
 
-               [MonoTODO]
                protected internal static void WriteAttributeExtensions 
(XmlWriter writer, SyndicationCategory category, string version)
                {
-                       throw new NotImplementedException ();
+                       category.WriteAttributeExtensions (writer, version);
                }
 
-               [MonoTODO]
                protected internal static void WriteAttributeExtensions 
(XmlWriter writer, SyndicationItem item, string version)
                {
-                       throw new NotImplementedException ();
+                       item.WriteAttributeExtensions (writer, version);
                }
 
-               [MonoTODO]
                protected internal static void WriteAttributeExtensions 
(XmlWriter writer, SyndicationLink link, string version)
                {
-                       throw new NotImplementedException ();
+                       link.WriteAttributeExtensions (writer, version);
                }
 
-               [MonoTODO]
                protected internal static void WriteAttributeExtensions 
(XmlWriter writer, SyndicationPerson person, string version)
                {
-                       throw new NotImplementedException ();
+                       person.WriteAttributeExtensions (writer, version);
                }
 
-               [MonoTODO]
                protected internal void WriteElementExtensions (XmlWriter 
writer, SyndicationCategory category, string version)
                {
-                       throw new NotImplementedException ();
+                       category.WriteElementExtensions (writer, version);
                }
 
-               [MonoTODO]
                protected internal static void WriteElementExtensions 
(XmlWriter writer, SyndicationItem item, string version)
                {
-                       throw new NotImplementedException ();
+                       item.WriteElementExtensions (writer, version);
                }
 
-               [MonoTODO]
                protected internal void WriteElementExtensions (XmlWriter 
writer, SyndicationLink link, string version)
                {
-                       throw new NotImplementedException ();
+                       link.WriteElementExtensions (writer, version);
                }
 
-               [MonoTODO]
                protected internal void WriteElementExtensions (XmlWriter 
writer, SyndicationPerson person, string version)
                {
-                       throw new NotImplementedException ();
+                       person.WriteElementExtensions (writer, version);
                }
 
                #endregion
@@ -228,7 +217,6 @@
                {
                        return base.ToString ();
                }
-
                #endregion
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationLink.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationLink.cs
        2007-12-15 05:11:27 UTC (rev 91349)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationLink.cs
        2007-12-15 11:25:08 UTC (rev 91350)
@@ -168,17 +168,14 @@
                        throw new NotImplementedException ();
                }
 
-
-               [MonoTODO]
                protected internal virtual void WriteAttributeExtensions 
(XmlWriter writer, string version)
                {
-                       throw new NotImplementedException ();
+                       extensions.WriteAttributeExtensions (writer, version);
                }
 
-               [MonoTODO]
                protected internal virtual void WriteElementExtensions 
(XmlWriter writer, string version)
                {
-                       throw new NotImplementedException ();
+                       extensions.WriteElementExtensions (writer, version);
                }
 
                public Uri GetAbsoluteUri ()

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationPerson.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationPerson.cs
      2007-12-15 05:11:27 UTC (rev 91349)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationPerson.cs
      2007-12-15 11:25:08 UTC (rev 91350)
@@ -106,17 +106,14 @@
                        throw new NotImplementedException ();
                }
 
-
-               [MonoTODO]
                protected internal virtual void WriteAttributeExtensions 
(XmlWriter writer, string version)
                {
-                       throw new NotImplementedException ();
+                       extensions.WriteAttributeExtensions (writer, version);
                }
 
-               [MonoTODO]
                protected internal virtual void WriteElementExtensions 
(XmlWriter writer, string version)
                {
-                       throw new NotImplementedException ();
+                       extensions.WriteElementExtensions (writer, version);
                }
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
  2007-12-15 05:11:27 UTC (rev 91349)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
  2007-12-15 11:25:08 UTC (rev 91350)
@@ -3,6 +3,7 @@
 System.Runtime.Serialization.Json/JsonWriterTest.cs
 System.ServiceModel.Syndication/Atom10ItemFormatterTest.cs
 System.ServiceModel.Syndication/Rss20ItemFormatterTest.cs
+System.ServiceModel.Syndication/SyndicationElementExtensionTest.cs
 System.ServiceModel.Syndication/SyndicationFeedTest.cs
 System.ServiceModel.Syndication/SyndicationItemTest.cs
 System.ServiceModel.Syndication/SyndicationLinkTest.cs

Modified: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/ChangeLog
    2007-12-15 05:11:27 UTC (rev 91349)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/ChangeLog
    2007-12-15 11:25:08 UTC (rev 91350)
@@ -1,3 +1,8 @@
+2007-12-15  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * SyndicationElementExtensionTest.cs : new test.
+       * TextSyndicationContentTest.cs : was missing in the previous commit.
+
 2007-12-11  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * TextSyndicationContentTest.cs : new test.

Added: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/SyndicationElementExtensionTest.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/SyndicationElementExtensionTest.cs
   2007-12-15 05:11:27 UTC (rev 91349)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/SyndicationElementExtensionTest.cs
   2007-12-15 11:25:08 UTC (rev 91350)
@@ -0,0 +1,210 @@
+//
+// SyndicationElementExtensionTest.cs
+//
+// Author:
+//     Atsushi Enomoto  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+using System.Xml.Serialization;
+using System.ServiceModel.Syndication;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Syndication
+{
+       [TestFixture]
+       public class SyndicationElementExtensionTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorExtensionNull ()
+               {
+                       new SyndicationElementExtension ((object) null);
+               }
+
+               [Test]
+               public void ConstructorXmlObjectSerializerNull ()
+               {
+                       // null XmlObjectSerializer is allowed.
+                       new SyndicationElementExtension (5, 
(XmlObjectSerializer) null);
+               }
+
+               [Test]
+               public void ConstructorOuterNameNull ()
+               {
+                       // null name strings are allowed.
+                       new SyndicationElementExtension (null, null, 5, null);
+               }
+
+               [Test]
+               public void ConstructorXmlSerializerNull ()
+               {
+                       // null XmlSerializer is allowed.
+                       new SyndicationElementExtension (5, (XmlSerializer) 
null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void ConstructorXmlSerializerNonSerializable ()
+               {
+                       // null XmlSerializer is allowed.
+                       new SyndicationElementExtension (new NonXmlSerializable 
(null), (XmlSerializer) null);
+               }
+
+               public class NonXmlSerializable
+               {
+                       public NonXmlSerializable (string dummy)
+                       {
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorXmlReaderNull ()
+               {
+                       new SyndicationElementExtension ((XmlReader) null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void ConstructorXmlReaderUnexpectedEndElement ()
+               {
+                       string xml = "<root></root>";
+                       XmlReader r = XmlReader.Create (new StringReader (xml));
+                       r.Read ();
+                       r.Read (); // at end element
+                       new SyndicationElementExtension (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void ConstructorXmlReaderUnexpectedText ()
+               {
+                       string xml = "<root>2</root>";
+                       XmlReader r = XmlReader.Create (new StringReader (xml));
+                       r.Read ();
+                       r.Read (); // at text
+                       new SyndicationElementExtension (r);
+               }
+
+               XmlWriter GetWriter (StringWriter sw)
+               {
+                       XmlWriterSettings s = new XmlWriterSettings ();
+                       s.OmitXmlDeclaration = true;
+                       return XmlWriter.Create (sw, s);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void WriteTo_NullWriter ()
+               {
+                       new SyndicationElementExtension (5).WriteTo (null);
+               }
+
+               [Test]
+               public void WriteTo_Reader ()
+               {
+                       string xml = "<root><child /><child2 /></root>";
+                       StringWriter sw = new StringWriter ();
+                       using (XmlWriter w = GetWriter (sw)) {
+                               XmlReader r = XmlReader.Create (new 
StringReader (xml));
+                               r.Read ();
+                               r.Read (); // at child
+                               new SyndicationElementExtension (r).WriteTo (w);
+                       }
+                       Assert.AreEqual ("<child></child>", sw.ToString ());
+               }
+
+               [Test]
+               public void WriteToTwice_Reader ()
+               {
+                       string xml = "<root><child /><child2 /></root>";
+                       StringWriter sw = new StringWriter ();
+                       using (XmlWriter w = GetWriter (sw)) {
+                               XmlReader r = XmlReader.Create (new 
StringReader (xml));
+                               r.Read ();
+                               r.Read (); // at child
+                               SyndicationElementExtension x = new 
SyndicationElementExtension (r);
+                               w.WriteStartElement ("root");
+                               x.WriteTo (w);
+                               x.WriteTo (w); // it is VALID.
+                               w.WriteEndElement ();
+                       }
+                       Assert.AreEqual 
("<root><child></child><child></child></root>", sw.ToString ());
+               }
+
+               [Test]
+               public void WriteTo_ExtensionObject ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       using (XmlWriter w = GetWriter (sw))
+                               new SyndicationElementExtension (5).WriteTo (w);
+                       Assert.AreEqual ("<int 
xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\";>5</int>", 
sw.ToString ());
+               }
+
+               [Test]
+               public void GetObject_DataContract ()
+               {
+                       new SyndicationElementExtension (5).GetObject<int> ();
+                       new SyndicationElementExtension (5).GetObject<double> 
();
+                       new SyndicationElementExtension ("5").GetObject<int> ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void GetObject_DataContract_XmlObjectSerializerNull ()
+               {
+                       new SyndicationElementExtension (5).GetObject<int> 
((XmlObjectSerializer) null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void GetObject_DataContract_XmlSerializerNull ()
+               {
+                       new SyndicationElementExtension (5).GetObject<int> 
((XmlSerializer) null);
+               }
+
+               [Test]
+               public void GetObject_XmlReader ()
+               {
+                       string xml = "<root>3</root>";
+                       XmlReader r = XmlReader.Create (new StringReader (xml));
+                       SyndicationElementExtension x = new 
SyndicationElementExtension (r);
+                       Assert.AreEqual (3, x.GetObject<int> (), "#1");
+                       Assert.AreEqual (3, x.GetObject<int> (), "#2"); // it 
is VALID
+               }
+
+               [Test]
+               [ExpectedException (typeof (SerializationException))]
+               public void GetObject_DataContractError ()
+               {
+                       new SyndicationElementExtension 
(DBNull.Value).GetObject<int> (); // Nullable<int> as well
+               }
+       }
+}


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/SyndicationElementExtensionTest.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/TextSyndicationContentTest.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/TextSyndicationContentTest.cs
        2007-12-15 05:11:27 UTC (rev 91349)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/TextSyndicationContentTest.cs
        2007-12-15 11:25:08 UTC (rev 91350)
@@ -0,0 +1,99 @@
+//
+// TextSyndicationContentTest.cs
+//
+// Author:
+//     Atsushi Enomoto  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+using System.Xml.Serialization;
+using System.ServiceModel.Syndication;
+using NUnit.Framework;
+
+using QName = System.Xml.XmlQualifiedName;
+
+namespace MonoTests.System.ServiceModel.Syndication
+{
+       [TestFixture]
+       public class TextSyndicationContentTest
+       {
+               [Test]
+               public void Constructor ()
+               {
+                       TextSyndicationContent t = new TextSyndicationContent 
(null); // hmm, null is allowed...
+                       Assert.IsNull (t.Text, "#0");
+
+                       t = new TextSyndicationContent ("test");
+                       Assert.AreEqual ("test", t.Text, "#1");
+                       Assert.AreEqual ("text", t.Type, "#2");
+
+                       t = new TextSyndicationContent ("test", 
TextSyndicationContentKind.Html);
+                       Assert.AreEqual ("html", t.Type, "#3");
+
+                       t = new TextSyndicationContent ("test", 
TextSyndicationContentKind.XHtml);
+                       Assert.AreEqual ("xhtml", t.Type, "#4");
+               }
+
+               [Test]
+               public void Clone ()
+               {
+                       TextSyndicationContent t = new TextSyndicationContent 
("test");
+                       t = t.Clone () as TextSyndicationContent;
+                       Assert.AreEqual ("test", t.Text, "#1");
+                       Assert.AreEqual ("text", t.Type, "#2");
+
+                       t = new TextSyndicationContent ("test", 
TextSyndicationContentKind.Html);
+                       t = t.Clone () as TextSyndicationContent;
+                       Assert.AreEqual ("html", t.Type, "#3");
+               }
+
+               [Test]
+               public void WriteTo ()
+               {
+                       TextSyndicationContent t = new TextSyndicationContent 
(null);
+                       StringWriter sw = new StringWriter ();
+                       using (XmlWriter w = CreateWriter (sw))
+                               t.WriteTo (w, "root", String.Empty);
+                       Assert.AreEqual ("<root type=\"text\"></root>", 
sw.ToString ());
+
+                       t = new TextSyndicationContent ("broken<b>html", 
TextSyndicationContentKind.Html);
+                       sw = new StringWriter ();
+                       using (XmlWriter w = CreateWriter (sw))
+                               t.WriteTo (w, "root", String.Empty);
+                       Assert.AreEqual ("<root 
type=\"html\">broken&lt;b&gt;html</root>", sw.ToString ());
+               }
+
+               XmlWriter CreateWriter (StringWriter sw)
+               {
+                       XmlWriterSettings s = new XmlWriterSettings ();
+                       s.OmitXmlDeclaration = true;
+                       return XmlWriter.Create (sw, s);
+               }
+       }
+}


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/TextSyndicationContentTest.cs
___________________________________________________________________
Name: svn:eol-style
   + native

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to