Author: atsushi
Date: 2007-12-15 13:07:49 -0500 (Sat, 15 Dec 2007)
New Revision: 91356

Added:
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/UrlSyndicationContentTest.cs
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/XmlSyndicationContentTest.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/SyndicationContent.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationElementExtensionCollection.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/UrlSyndicationContent.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/XmlSyndicationContent.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/Rss20ItemFormatterTest.cs
Log:
2007-12-15  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * Rss20ItemFormatter.cs : write remaining properties in item.
        * UrlSyndicationContent.cs : implemented.
        * XmlSyndicationContent.cs, SyndicationContent.cs,
          SyndicationElementExtensionCollection.cs : mostly implemented; now
          I mostly found that those unimplemented stuff were bound to
          SyndicationElementExtension constructors.

        * Rss20ItemFormatterTest.cs : added test for writing properties.
        * XmlSyndicationContentTest.cs, UrlSyndicationContentTest.cs : new.



Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog
 2007-12-15 18:03:07 UTC (rev 91355)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog
 2007-12-15 18:07:49 UTC (rev 91356)
@@ -1,5 +1,14 @@
 2007-12-15  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * Rss20ItemFormatter.cs : write remaining properties in item.
+       * UrlSyndicationContent.cs : implemented.
+       * XmlSyndicationContent.cs, SyndicationContent.cs,
+         SyndicationElementExtensionCollection.cs : mostly implemented; now
+         I mostly found that those unimplemented stuff were bound to
+         SyndicationElementExtension constructors.
+
+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.

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 18:03:07 UTC (rev 91355)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/Rss20ItemFormatter.cs
     2007-12-15 18:07:49 UTC (rev 91356)
@@ -28,6 +28,7 @@
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
+using System.Globalization;
 using System.IO;
 using System.Runtime.Serialization;
 using System.Text;
@@ -131,7 +132,6 @@
                        throw new NotImplementedException ();
                }
 
-               // FIXME: output every non-ISyndicationElement properties (id, 
pubDate, etc.)
                void WriteXml (XmlWriter writer, bool writeRoot)
                {
                        if (writer == null)
@@ -142,6 +142,15 @@
                        if (writeRoot)
                                writer.WriteStartElement ("item");
 
+                       if (Item.BaseUri != null)
+                               writer.WriteAttributeString ("xml:base", 
Item.BaseUri.ToString ());
+                       if (Item.Id != null) {
+                               writer.WriteStartElement ("guid");
+                               writer.WriteAttributeString ("isPermaLink", 
"false");
+                               writer.WriteString (Item.Id);
+                               writer.WriteEndElement ();
+                       }
+
                        if (Item.Title != null) {
                                writer.WriteStartElement ("title");
                                writer.WriteString (Item.Title.Text);
@@ -172,7 +181,7 @@
                                writer.WriteStartElement ("description");
                                writer.WriteEndElement ();
                        }
-                       // FIXME; what to do for Contributors?
+
                        foreach (SyndicationLink link in Item.Links)
                                if (link != null) {
                                        writer.WriteStartElement ("link");
@@ -182,8 +191,16 @@
                                        writer.WriteEndElement ();
                                }
 
-                       // Contributors are part of Atom extension
-                       if (SerializeExtensionsAsAtom)
+                       if (Item.SourceFeed != null)
+                               Item.SourceFeed.SaveAsRss20 (writer);
+
+                       if (!Item.PublishDate.Equals (default 
(DateTimeOffset))) {
+                               writer.WriteStartElement ("pubDate");
+                               writer.WriteString (ToRFC822DateString 
(Item.PublishDate));
+                               writer.WriteEndElement ();
+                       }
+
+                       if (SerializeExtensionsAsAtom) {
                                foreach (SyndicationPerson contributor in 
Item.Contributors) {
                                        if (contributor != null) {
                                                writer.WriteStartElement 
("contributor", AtomNamespace);
@@ -196,8 +213,38 @@
                                        }
                                }
 
+                               if (!Item.LastUpdatedTime.Equals (default 
(DateTimeOffset))) {
+                                       writer.WriteStartElement ("updated", 
AtomNamespace);
+                                       // FIXME: how to handle offset part?
+                                       writer.WriteString (XmlConvert.ToString 
(Item.LastUpdatedTime.DateTime, XmlDateTimeSerializationMode.RoundtripKind));
+                                       writer.WriteEndElement ();
+                               }
+
+                               if (Item.Copyright != null)
+                                       Item.Copyright.WriteTo (writer, 
"rights", AtomNamespace);
+
+                               if (Item.Content != null)
+                                       Item.Content.WriteTo (writer, 
"content", AtomNamespace);
+                       }
+
                        if (writeRoot)
                                writer.WriteEndElement ();
                }
+
+               // FIXME: DateTimeOffset.ToString() needs another overload.
+               // When it is implemented, just remove ".DateTime" parts below.
+               string ToRFC822DateString (DateTimeOffset date)
+               {
+                       switch (date.DateTime.Kind) {
+                       case DateTimeKind.Utc:
+                               return date.DateTime.ToString ("ddd, dd MMM 
yyyy HH:mm:ss 'Z'", DateTimeFormatInfo.InvariantInfo);
+                       case DateTimeKind.Local:
+                               StringBuilder sb = new StringBuilder 
(date.DateTime.ToString ("ddd, dd MMM yyyy HH:mm:ss zzz", 
DateTimeFormatInfo.InvariantInfo));
+                               sb.Remove (sb.Length - 3, 1);
+                               return sb.ToString (); // remove ':' from +hh:mm
+                       default:
+                               return date.DateTime.ToString ("ddd, dd MMM 
yyyy HH:mm:ss", DateTimeFormatInfo.InvariantInfo);
+                       }
+               }
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationContent.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationContent.cs
     2007-12-15 18:03:07 UTC (rev 91355)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationContent.cs
     2007-12-15 18:07:49 UTC (rev 91356)
@@ -60,28 +60,24 @@
                        return new UrlSyndicationContent (url, mediaType);
                }
 
-               [MonoTODO]
                public static XmlSyndicationContent CreateXmlContent (object 
dataContractObject)
                {
-                       throw new NotImplementedException ();
+                       return new XmlSyndicationContent (null, 
dataContractObject, (XmlObjectSerializer) null);
                }
 
-               [MonoTODO]
                public static XmlSyndicationContent CreateXmlContent (object 
dataContractObject, XmlObjectSerializer dataContractSerializer)
                {
-                       throw new NotImplementedException ();
+                       return new XmlSyndicationContent (null, 
dataContractObject, dataContractSerializer);
                }
 
-               [MonoTODO]
                public static XmlSyndicationContent CreateXmlContent (object 
xmlSerializerObject, XmlSerializer serializer)
                {
-                       throw new NotImplementedException ();
+                       return new XmlSyndicationContent (null, 
xmlSerializerObject, serializer);
                }
 
-               [MonoTODO]
                public static XmlSyndicationContent CreateXmlContent (XmlReader 
reader)
                {
-                       throw new NotImplementedException ();
+                       return new XmlSyndicationContent (reader);
                }
 
                #endregion

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationElementExtensionCollection.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationElementExtensionCollection.cs
  2007-12-15 18:03:07 UTC (rev 91355)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationElementExtensionCollection.cs
  2007-12-15 18:07:49 UTC (rev 91356)
@@ -50,46 +50,40 @@
                                Add (item);
                }
 
-               [MonoTODO]
                public void Add (object extension)
                {
-                       throw new NotImplementedException ();
+                       Add (new SyndicationElementExtension (extension));
                }
 
-               [MonoTODO]
                public void Add (object dataContractExtension, 
DataContractSerializer serializer)
                {
-                       throw new NotImplementedException ();
+                       Add (new SyndicationElementExtension 
(dataContractExtension, serializer));
                }
 
-               [MonoTODO]
                public void Add (object xmlSerializerExtension, XmlSerializer 
serializer)
                {
-                       throw new NotImplementedException ();
+                       Add (new SyndicationElementExtension 
(xmlSerializerExtension, serializer));
                }
 
-               [MonoTODO]
                public void Add (string outerName, string outerNamespace, 
object dataContractExtension)
                {
-                       throw new NotImplementedException ();
+                       Add (new SyndicationElementExtension (outerName, 
outerNamespace, dataContractExtension));
                }
 
-               [MonoTODO]
                public void Add (string outerName, string outerNamespace, 
object dataContractExtension, XmlObjectSerializer dataContractSerializer)
                {
-                       throw new NotImplementedException ();
+                       Add (new SyndicationElementExtension (outerName, 
outerNamespace, dataContractExtension, dataContractSerializer));
                }
 
-               [MonoTODO]
                public void Add (XmlReader xmlReader)
                {
-                       throw new NotImplementedException ();
+                       Add (new SyndicationElementExtension (xmlReader));
                }
 
-               [MonoTODO]
+               [MonoTODO ("Find out what is expected here")]
                protected override void ClearItems ()
                {
-                       throw new NotImplementedException ();
+                       base.ClearItems ();
                }
 
                [MonoTODO]
@@ -98,40 +92,57 @@
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO]
                protected override void InsertItem (int index, 
SyndicationElementExtension item)
                {
-                       throw new NotImplementedException ();
+                       if (item == null)
+                               throw new ArgumentNullException ("item");
+                       base.InsertItem (index, item);
                }
 
-               [MonoTODO]
                public Collection<TExtension> ReadElementExtensions<TExtension> 
(string extensionName, string extensionNamespace)
                {
-                       throw new NotImplementedException ();
+                       Collection<TExtension> c = new Collection<TExtension> 
();
+                       foreach (SyndicationElementExtension e in this)
+                               if (e.OuterName == extensionName && 
e.OuterNamespace == extensionNamespace)
+                                       c.Add (e.GetObject<TExtension> ());
+                       return c;
                }
 
-               [MonoTODO]
                public Collection<TExtension> ReadElementExtensions<TExtension> 
(string extensionName, string extensionNamespace, XmlObjectSerializer 
serializer)
                {
-                       throw new NotImplementedException ();
+                       if (serializer == null)
+                               throw new ArgumentNullException ("serializer");
+
+                       Collection<TExtension> c = new Collection<TExtension> 
();
+                       foreach (SyndicationElementExtension e in this)
+                               if (e.OuterName == extensionName && 
e.OuterNamespace == extensionNamespace)
+                                       c.Add (e.GetObject<TExtension> 
(serializer));
+                       return c;
                }
 
-               [MonoTODO]
                public Collection<TExtension> ReadElementExtensions<TExtension> 
(string extensionName, string extensionNamespace, XmlSerializer serializer)
                {
-                       throw new NotImplementedException ();
+                       if (serializer == null)
+                               throw new ArgumentNullException ("serializer");
+
+                       Collection<TExtension> c = new Collection<TExtension> 
();
+                       foreach (SyndicationElementExtension e in this)
+                               if (e.OuterName == extensionName && 
e.OuterNamespace == extensionNamespace)
+                                       c.Add (e.GetObject<TExtension> 
(serializer));
+                       return c;
                }
 
-               [MonoTODO]
+               [MonoTODO ("Find out what is expected here")]
                protected override void RemoveItem (int index)
                {
-                       throw new NotImplementedException ();
+                       base.RemoveItem (index);
                }
 
-               [MonoTODO]
                protected override void SetItem (int index, 
SyndicationElementExtension item)
                {
-                       throw new NotImplementedException ();
+                       if (item == null)
+                               throw new ArgumentNullException ("item");
+                       base.SetItem (index, item);
                }
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/UrlSyndicationContent.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/UrlSyndicationContent.cs
  2007-12-15 18:03:07 UTC (rev 91355)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/UrlSyndicationContent.cs
  2007-12-15 18:07:49 UTC (rev 91356)
@@ -37,38 +37,45 @@
 {
        public class UrlSyndicationContent : SyndicationContent
        {
-               [MonoTODO]
+               Uri url;
+               string media_type;
+
                public UrlSyndicationContent (Uri url, string mediaType)
                {
-                       throw new NotImplementedException ();
+                       if (url == null)
+                               throw new ArgumentNullException ("url");
+                       this.url = url;
+                       this.media_type = mediaType;
                }
 
-               [MonoTODO]
                protected UrlSyndicationContent (UrlSyndicationContent source)
                {
-                       throw new NotImplementedException ();
+                       if (source == null)
+                               throw new ArgumentNullException ("source");
+                       url = source.url;
+                       media_type = source.media_type;
                }
 
-               [MonoTODO]
                public override SyndicationContent Clone ()
                {
-                       throw new NotImplementedException ();
+                       return new UrlSyndicationContent (this);
                }
 
-               [MonoTODO]
                protected override void WriteContentsTo (XmlWriter writer)
                {
-                       throw new NotImplementedException ();
+                       if (writer == null)
+                               throw new ArgumentNullException ("writer");
+                       if (media_type != null)
+                               writer.WriteAttributeString ("type", 
media_type);
+                       writer.WriteAttributeString ("src", url.ToString ());
                }
 
-               [MonoTODO]
                public Uri Url {
-                       get { throw new NotImplementedException (); }
+                       get { return url; }
                }
 
-               [MonoTODO]
                public override string Type {
-                       get { throw new NotImplementedException (); }
+                       get { return media_type; }
                }
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/XmlSyndicationContent.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/XmlSyndicationContent.cs
  2007-12-15 18:03:07 UTC (rev 91355)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/XmlSyndicationContent.cs
  2007-12-15 18:07:49 UTC (rev 91356)
@@ -38,80 +38,81 @@
 {
        public class XmlSyndicationContent : SyndicationContent
        {
-               [MonoTODO]
+               SyndicationElementExtension extension;
+               string type;
+
                public XmlSyndicationContent (XmlReader reader)
                {
-                       throw new NotImplementedException ();
+                       extension = new SyndicationElementExtension (reader);
                }
 
-               [MonoTODO]
                public XmlSyndicationContent (string type, object 
dataContractExtension, XmlObjectSerializer dataContractSerializer)
                {
-                       throw new NotImplementedException ();
+                       this.type = type;
+                       extension = new SyndicationElementExtension 
(dataContractExtension, dataContractSerializer);
                }
 
-               [MonoTODO]
                public XmlSyndicationContent (string type, object 
xmlSerializerExtension, XmlSerializer serializer)
                {
-                       throw new NotImplementedException ();
+                       this.type = type;
+                       extension = new SyndicationElementExtension 
(xmlSerializerExtension, serializer);
                }
 
-               [MonoTODO]
                public XmlSyndicationContent (string type, 
SyndicationElementExtension extension)
                {
-                       throw new NotImplementedException ();
+                       this.type = type;
+                       if (extension == null)
+                               throw new ArgumentNullException ("extension");
+                       this.extension = extension;
                }
 
-               [MonoTODO]
                protected XmlSyndicationContent (XmlSyndicationContent source)
                {
-                       throw new NotImplementedException ();
+                       if (source == null)
+                               throw new ArgumentNullException ("source");
+                       type = source.type;
+                       extension = source.extension;
                }
 
-               [MonoTODO]
                public override SyndicationContent Clone ()
                {
-                       throw new NotImplementedException ();
+                       return new XmlSyndicationContent (this);
                }
 
-               [MonoTODO]
                public XmlDictionaryReader GetReaderAtContent ()
                {
-                       throw new NotImplementedException ();
+                       XmlReader r = extension.GetReader ();
+                       if (!(r is XmlDictionaryReader))
+                               r = XmlDictionaryReader.CreateDictionaryReader 
(r);
+                       return (XmlDictionaryReader) r;
                }
 
-               [MonoTODO]
                public TContent ReadContent<TContent> ()
                {
-                       throw new NotImplementedException ();
+                       return extension.GetObject<TContent> ();
                }
 
-               [MonoTODO]
                public TContent ReadContent<TContent> (XmlObjectSerializer 
serializer)
                {
-                       throw new NotImplementedException ();
+                       return extension.GetObject<TContent> (serializer);
                }
 
-               [MonoTODO]
                public TContent ReadContent<TContent> (XmlSerializer serializer)
                {
-                       throw new NotImplementedException ();
+                       return extension.GetObject<TContent> (serializer);
                }
 
-               [MonoTODO]
                protected override void WriteContentsTo (XmlWriter writer)
                {
-                       throw new NotImplementedException ();
+                       extension.WriteTo (writer);
                }
 
-               [MonoTODO]
                public SyndicationElementExtension Extension {
-                       get { throw new NotImplementedException (); }
+                       get { return extension; }
                }
 
-               [MonoTODO]
                public override string Type {
-                       get { throw new NotImplementedException (); }
+                       get { return type ?? "text/xml"; }
                }
        }
 }

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 18:03:07 UTC (rev 91355)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
  2007-12-15 18:07:49 UTC (rev 91356)
@@ -8,3 +8,5 @@
 System.ServiceModel.Syndication/SyndicationItemTest.cs
 System.ServiceModel.Syndication/SyndicationLinkTest.cs
 System.ServiceModel.Syndication/TextSyndicationContentTest.cs
+System.ServiceModel.Syndication/UrlSyndicationContentTest.cs
+System.ServiceModel.Syndication/XmlSyndicationContentTest.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 18:03:07 UTC (rev 91355)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/ChangeLog
    2007-12-15 18:07:49 UTC (rev 91356)
@@ -1,5 +1,10 @@
 2007-12-15  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * Rss20ItemFormatterTest.cs : added test for writing properties.
+       * XmlSyndicationContentTest.cs, UrlSyndicationContentTest.cs : new.
+
+2007-12-15  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * SyndicationElementExtensionTest.cs : new test.
        * TextSyndicationContentTest.cs : was missing in the previous commit.
 

Modified: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/Rss20ItemFormatterTest.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/Rss20ItemFormatterTest.cs
    2007-12-15 18:03:07 UTC (rev 91355)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/Rss20ItemFormatterTest.cs
    2007-12-15 18:07:49 UTC (rev 91356)
@@ -122,7 +122,7 @@
                }
 
                [Test]
-               public void WriteTo_Category ()
+               public void WriteTo_CategoryAuthorsContributors ()
                {
                        SyndicationItem item = new SyndicationItem ();
                        item.Categories.Add (new SyndicationCategory ("myname", 
"myscheme", "mylabel"));
@@ -136,6 +136,24 @@
                }
 
                [Test]
+               public void WriteTo ()
+               {
+                       SyndicationItem item = new SyndicationItem ();
+                       item.BaseUri = new Uri ("http://mono-project.com";);
+                       item.Copyright = new TextSyndicationContent ("No rights 
reserved");
+                       item.Content = new XmlSyndicationContent (null, 5, 
(XmlObjectSerializer) null);
+                       item.Id = "urn:myid";
+                       item.PublishDate = new DateTimeOffset 
(DateTime.SpecifyKind (new DateTime (2000, 1, 1), DateTimeKind.Utc));
+                       item.LastUpdatedTime = new DateTimeOffset 
(DateTime.SpecifyKind (new DateTime (2008, 1, 1), DateTimeKind.Utc));
+                       //item.SourceFeed = new SyndicationFeed ();
+
+                       StringWriter sw = new StringWriter ();
+                       using (XmlWriter w = CreateWriter (sw))
+                               new Rss20ItemFormatter (item).WriteTo (w);
+                       Assert.AreEqual ("<item 
xml:base=\"http://mono-project.com/\";><guid 
isPermaLink=\"false\">urn:myid</guid><description />" + /* "<source></source>" 
+ */ "<pubDate>Sat, 01 Jan 2000 00:00:00 Z</pubDate><updated 
xmlns=\"http://www.w3.org/2005/Atom\";>2008-01-01T00:00:00Z</updated><rights 
type=\"text\" xmlns=\"http://www.w3.org/2005/Atom\";>No rights 
reserved</rights><content type=\"text/xml\" 
xmlns=\"http://www.w3.org/2005/Atom\";><int 
xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\";>5</int></content></item>",
 sw.ToString ());
+               }
+
+               [Test]
                public void SerializeExtensionsAsAtomFalse ()
                {
                        SyndicationItem item = new SyndicationItem ();

Added: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/UrlSyndicationContentTest.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/UrlSyndicationContentTest.cs
 2007-12-15 18:03:07 UTC (rev 91355)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/UrlSyndicationContentTest.cs
 2007-12-15 18:07:49 UTC (rev 91356)
@@ -0,0 +1,97 @@
+//
+// UrlSyndicationContentTest.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 UrlSyndicationContentTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNullUrl ()
+               {
+                       new UrlSyndicationContent (null, "text/plain");
+               }
+
+               [Test]
+               public void Constructor ()
+               {
+                       Uri uri = new Uri ("http://mono-project.com";);
+                       UrlSyndicationContent t = new UrlSyndicationContent 
(uri, null);
+                       t = new UrlSyndicationContent (uri, "text/plain");
+                       Assert.AreEqual (uri, t.Url, "#1");
+                       Assert.AreEqual ("text/plain", t.Type, "#2");
+               }
+
+               [Test]
+               public void Clone ()
+               {
+                       Uri uri = new Uri ("http://mono-project.com";);
+                       UrlSyndicationContent t = new UrlSyndicationContent 
(uri, "text/plain");
+                       t = t.Clone () as UrlSyndicationContent;
+                       Assert.AreEqual (uri, t.Url, "#1");
+                       Assert.AreEqual ("text/plain", t.Type, "#2");
+               }
+
+               [Test]
+               public void WriteTo ()
+               {
+                       Uri uri = new Uri ("http://mono-project.com/";);
+                       UrlSyndicationContent t = new UrlSyndicationContent 
(uri, null);
+                       StringWriter sw = new StringWriter ();
+                       using (XmlWriter w = CreateWriter (sw))
+                               t.WriteTo (w, "root", String.Empty);
+                       Assert.AreEqual ("<root type=\"\" 
src=\"http://mono-project.com/\"; />", sw.ToString ());
+
+                       t = new UrlSyndicationContent (uri, 
"application/xml+svg");
+                       sw = new StringWriter ();
+                       using (XmlWriter w = CreateWriter (sw))
+                               t.WriteTo (w, "root", String.Empty);
+                       Assert.AreEqual ("<root type=\"application/xml+svg\" 
src=\"http://mono-project.com/\"; />", 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/UrlSyndicationContentTest.cs
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Added: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/XmlSyndicationContentTest.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/XmlSyndicationContentTest.cs
 2007-12-15 18:03:07 UTC (rev 91355)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/XmlSyndicationContentTest.cs
 2007-12-15 18:07:49 UTC (rev 91356)
@@ -0,0 +1,116 @@
+//
+// XmlSyndicationContentTest.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 XmlSyndicationContentTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNullReader ()
+               {
+                       new XmlSyndicationContent ((XmlReader) null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNullExtensionObject ()
+               {
+                       new XmlSyndicationContent ("text/plain", null, 
(XmlObjectSerializer) null);
+               }
+
+               [Test]
+               public void ConstructorNullSerializer ()
+               {
+                       // allowed
+                       new XmlSyndicationContent ("text/plain", 5, 
(XmlObjectSerializer) null);
+                       new XmlSyndicationContent ("text/plain", 5, 
(XmlSerializer) null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNullExtension ()
+               {
+                       new XmlSyndicationContent ("text/plain", null);
+               }
+
+               [Test]
+               public void ConstructorNullType ()
+               {
+                       // allowed
+                       new XmlSyndicationContent (null, 5, 
(XmlObjectSerializer) null);
+               }
+
+               [Test]
+               public void Type ()
+               {
+                       XmlSyndicationContent t = new XmlSyndicationContent 
(null, 3, (XmlObjectSerializer) null);
+                       Assert.AreEqual ("text/xml", t.Type, "#1");
+                       t = new XmlSyndicationContent ("text/plain", 3, 
(XmlObjectSerializer) null);
+                       Assert.AreEqual ("text/plain", t.Type, "#2");
+               }
+
+               [Test]
+               public void Clone ()
+               {
+                       XmlSyndicationContent t = new XmlSyndicationContent 
("text/plain", 3, (XmlObjectSerializer) null);
+                       t = t.Clone () as XmlSyndicationContent;
+                       Assert.AreEqual ("text/plain", t.Type, "#1");
+               }
+
+               [Test]
+               public void WriteTo ()
+               {
+                       XmlSyndicationContent t = new XmlSyndicationContent 
("text/plain", 6, (XmlObjectSerializer) null);
+                       StringWriter sw = new StringWriter ();
+                       using (XmlWriter w = CreateWriter (sw))
+                               t.WriteTo (w, "root", String.Empty);
+                       Assert.AreEqual ("<root type=\"text/plain\"><int 
xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\";>6</int></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/XmlSyndicationContentTest.cs
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

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

Reply via email to