Author: atsushi
Date: 2007-12-10 04:07:54 -0500 (Mon, 10 Dec 2007)
New Revision: 91029

Added:
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationExtensions.cs
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/SyndicationLinkTest.cs
Modified:
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationElementExtensionCollection.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationLink.cs
   trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
Log:
2007-12-10  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * SyndicationElementExtensionCollection.cs : added copy .ctor().
        * SyndicationLink.cs : implemented everything but read/write part.

        * SyndicationLinkTest.cs : new test.



Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog
 2007-12-10 07:32:23 UTC (rev 91028)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog
 2007-12-10 09:07:54 UTC (rev 91029)
@@ -1,5 +1,10 @@
 2007-12-10  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * SyndicationElementExtensionCollection.cs : added copy .ctor().
+       * SyndicationLink.cs : implemented everything but read/write part.
+
+2007-12-10  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * Atom10FeedFormatter.cs Atom10FeedFormatter_1.cs
          Atom10ItemFormatter.cs Atom10ItemFormatter_1.cs
          Rss20FeedFormatter.cs Rss20FeedFormatter_1.cs

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-10 07:32:23 UTC (rev 91028)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationElementExtensionCollection.cs
  2007-12-10 09:07:54 UTC (rev 91029)
@@ -42,6 +42,14 @@
                {
                }
 
+               internal SyndicationElementExtensionCollection 
(IEnumerable<SyndicationElementExtension> source)
+               {
+                       if (source == null)
+                               throw new ArgumentNullException ("source");
+                       foreach (SyndicationElementExtension item in source)
+                               Add (item);
+               }
+
                [MonoTODO]
                public void Add (object extension)
                {

Added: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationExtensions.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationExtensions.cs
  2007-12-10 07:32:23 UTC (rev 91028)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationExtensions.cs
  2007-12-10 09:07:54 UTC (rev 91029)
@@ -0,0 +1,69 @@
+//
+// SyndicationExtensions.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;
+
+namespace System.ServiceModel.Syndication
+{
+       // ISyndicationElement helper.
+       internal class SyndicationExtensions
+       {
+               Dictionary<XmlQualifiedName, string> attributes;
+               SyndicationElementExtensionCollection elements;
+
+               public Dictionary<XmlQualifiedName, string> Attributes {
+                       get {
+                               if (attributes == null)
+                                       attributes = new 
Dictionary<XmlQualifiedName, string> ();
+                               return attributes;
+                       }
+               }
+
+               public SyndicationElementExtensionCollection Elements {
+                       get {
+                               if (elements == null)
+                                       elements = new 
SyndicationElementExtensionCollection ();
+                               return elements;
+                       }
+               }
+
+               public SyndicationExtensions Clone ()
+               {
+                       SyndicationExtensions ret = new SyndicationExtensions 
();
+                       ret.attributes = attributes == null ? null : new 
Dictionary<XmlQualifiedName, string> (attributes);
+                       ret.elements = elements == null ? null : new 
SyndicationElementExtensionCollection (elements);
+                       return ret;
+               }
+       }
+}
+


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

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-10 07:32:23 UTC (rev 91028)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Syndication/SyndicationLink.cs
        2007-12-10 09:07:54 UTC (rev 91029)
@@ -37,111 +37,123 @@
 {
        public class SyndicationLink : ISyndicationElement
        {
-               [MonoTODO]
+               #region Static members
+
                public static SyndicationLink CreateAlternateLink (Uri uri)
                {
-                       throw new NotImplementedException ();
+                       return CreateAlternateLink (uri, null);
                }
 
-               [MonoTODO]
                public static SyndicationLink CreateAlternateLink (Uri uri, 
string mediaType)
                {
-                       throw new NotImplementedException ();
+                       return new SyndicationLink (uri, "alternate", null, 
mediaType, 0);
                }
 
-               [MonoTODO]
                public static SyndicationLink CreateMediaEnclosureLink (Uri 
uri, string mediaType, long length)
 
                {
-                       throw new NotImplementedException ();
+                       return new SyndicationLink (uri, "enclosure", null, 
mediaType, length);
                }
 
-               [MonoTODO]
                public static SyndicationLink CreateSelfLink (Uri uri)
                {
-                       throw new NotImplementedException ();
+                       return CreateSelfLink (uri, null);
                }
 
-               [MonoTODO]
                public static SyndicationLink CreateSelfLink (Uri uri, string 
mediaType)
                {
-                       throw new NotImplementedException ();
+                       return new SyndicationLink (uri, "self", null, 
mediaType, 0);
                }
 
-               [MonoTODO]
+               #endregion
+
+               #region Instance members
+
+               Uri base_uri, href;
+               long length;
+               string rel, title, type;
+               SyndicationExtensions extensions = new SyndicationExtensions ();
+
                public SyndicationLink ()
                {
-                       throw new NotImplementedException ();
                }
 
-               [MonoTODO]
                public SyndicationLink (Uri uri)
                {
-                       throw new NotImplementedException ();
+                       Uri = uri;
                }
 
-               [MonoTODO]
                public SyndicationLink (Uri uri, string relationshipType, 
string title, string mediaType, long length)
                {
-                       throw new NotImplementedException ();
+                       Uri = uri;
+                       RelationshipType = relationshipType;
+                       Title = title;
+                       MediaType = mediaType;
+                       Length = length;
                }
 
-               [MonoTODO]
                protected SyndicationLink (SyndicationLink source)
                {
-                       throw new NotImplementedException ();
+                       if (source == null)
+                               throw new ArgumentNullException ("source");
+                       base_uri = source.base_uri;
+                       href = source.href;
+                       length = source.length;
+                       rel = source.rel;
+                       title = source.title;
+                       type = source.type;
+                       extensions = source.extensions.Clone ();
                }
 
-               [MonoTODO]
                public Dictionary<XmlQualifiedName, string> AttributeExtensions 
{
-                       get { throw new NotImplementedException (); }
+                       get { return extensions.Attributes; }
                }
 
-               [MonoTODO]
                public SyndicationElementExtensionCollection ElementExtensions {
-                       get { throw new NotImplementedException (); }
+                       get { return extensions.Elements; }
                }
 
-               [MonoTODO]
                public Uri BaseUri {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return base_uri; }
+                       set {
+                               if (value != null && !value.IsAbsoluteUri)
+                                       throw new ArgumentException ("Base URI 
must not be relative");
+                               base_uri = value;
+                       }
                }
 
-               [MonoTODO]
                public long Length {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return length; }
+                       set {
+                               if (length < 0)
+                                       throw new ArgumentOutOfRangeException 
("length");
+                               length = value;
+                       }
                }
 
-               [MonoTODO]
                public string MediaType {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return type; }
+                       set { type = value; }
                }
 
-               [MonoTODO]
                public string RelationshipType {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return rel; }
+                       set { rel = value; }
                }
 
-               [MonoTODO]
                public string Title {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return title; }
+                       set { title = value; }
                }
 
-               [MonoTODO]
                public Uri Uri {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return href; }
+                       set { href = value; }
                }
 
-               [MonoTODO]
                public virtual SyndicationLink Clone ()
                {
-                       throw new NotImplementedException ();
+                       return new SyndicationLink (this);
                }
 
                [MonoTODO]
@@ -169,10 +181,14 @@
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO]
                public Uri GetAbsoluteUri ()
                {
-                       throw new NotImplementedException ();
+                       if (href == null)
+                               return null;
+                       // our BaseUri is always absolute (unlike .NET).
+                       return  base_uri != null ? new Uri (base_uri, 
href.ToString ()) : href.IsAbsoluteUri ? href : null;
                }
+
+               #endregion
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources   
    2007-12-10 07:32:23 UTC (rev 91028)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources   
    2007-12-10 09:07:54 UTC (rev 91029)
@@ -21,6 +21,7 @@
 System.ServiceModel.Syndication/SyndicationContent.cs
 System.ServiceModel.Syndication/SyndicationElementExtension.cs
 System.ServiceModel.Syndication/SyndicationElementExtensionCollection.cs
+System.ServiceModel.Syndication/SyndicationExtensions.cs
 System.ServiceModel.Syndication/SyndicationFeed.cs
 System.ServiceModel.Syndication/SyndicationFeedFormatter.cs
 System.ServiceModel.Syndication/SyndicationItem.cs

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-10 07:32:23 UTC (rev 91028)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
  2007-12-10 09:07:54 UTC (rev 91029)
@@ -1,3 +1,4 @@
 System.Runtime.Serialization.Json/DataContractJsonSerializerTest.cs
 System.Runtime.Serialization.Json/JsonReaderTest.cs
 System.Runtime.Serialization.Json/JsonWriterTest.cs
+System.ServiceModel.Syndication/SyndicationLinkTest.cs

Added: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/ChangeLog
    2007-12-10 07:32:23 UTC (rev 91028)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/ChangeLog
    2007-12-10 09:07:54 UTC (rev 91029)
@@ -0,0 +1,3 @@
+2007-12-10  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * SyndicationLinkTest.cs : new test.


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/ChangeLog
___________________________________________________________________
Name: svn:executable
   + *

Added: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/SyndicationLinkTest.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/SyndicationLinkTest.cs
       2007-12-10 07:32:23 UTC (rev 91028)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/SyndicationLinkTest.cs
       2007-12-10 09:07:54 UTC (rev 91029)
@@ -0,0 +1,206 @@
+//
+// SyndicationLinkTest.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.ServiceModel.Syndication;
+using NUnit.Framework;
+
+using QName = System.Xml.XmlQualifiedName;
+
+namespace MonoTests.System.ServiceModel.Syndication
+{
+       [TestFixture]
+       public class SyndicationLinkTest
+       {
+               [Test]
+               public void Constructor ()
+               {
+                       // null Uri is allowed
+                       SyndicationLink link = new SyndicationLink (null);
+
+                       link = new SyndicationLink (new Uri ("empty.xml", 
UriKind.Relative));
+                       Assert.AreEqual ("empty.xml", link.Uri.ToString (), 
"#1-1");
+                       Assert.AreEqual (null, link.BaseUri, "#1-2");
+                       Assert.AreEqual (0, link.Length, "#1-3");
+                       Assert.AreEqual (null, link.MediaType, "#1-4");
+
+                       link = new SyndicationLink (null, null, null, null, 0);
+               }
+
+               [Test]
+               public void TestUri ()
+               {
+                       SyndicationLink link = new SyndicationLink (new Uri 
("empty.xml", UriKind.Relative));
+                       link.Uri = null;
+                       Assert.IsNull (link.Uri, "#1");
+                       Assert.IsNull (link.GetAbsoluteUri (), "#2");
+               }
+
+               [Test]
+               public void TestBaseUri ()
+               {
+                       // relative
+                       SyndicationLink link = new SyndicationLink (new Uri 
("empty.xml", UriKind.Relative));
+                       Assert.IsNull (link.BaseUri, "#1");
+
+                       // absolute
+                       link = new SyndicationLink (new Uri 
("http://mono-project.com/index.rss";));
+                       Assert.IsNull (link.BaseUri, "#2");
+
+                       // absolute #2
+                       link = new SyndicationLink ();
+                       link.Uri = new Uri 
("http://mono-project.com/index.rss";);
+                       Assert.IsNull (link.BaseUri, "#3");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               [Category ("NotDotNet")] // LAMESPEC. See below.
+               public void SetRelativeUriAsBaseUri ()
+               {
+                       SyndicationLink link = new SyndicationLink (new Uri 
("empty.xml", UriKind.Relative));
+                       // LAMESPEC: setting relative Uri as BaseUri is allowed 
(likely broken)
+                       link.BaseUri = new Uri ("base.xml", UriKind.Relative);
+
+                       // and below causes ArgumentOutOfRangeException.
+                       // Assert.IsNull (link.GetAbsoluteUri (), "#1");
+               }
+
+               [Test]
+               public void TestMediaType ()
+               {
+                       SyndicationLink link = new SyndicationLink (new Uri 
("http://mono-project.com/index.rss";));
+                       link.MediaType = "text/xml";
+                       Assert.AreEqual ("text/xml", link.MediaType, "#1");
+                       link.MediaType = null;
+                       Assert.IsNull (link.MediaType, "#2");
+                       link.MediaType = "WTF";
+               }
+
+               [Test]
+               public void Length ()
+               {
+                       SyndicationLink link = new SyndicationLink (new Uri 
("http://mono-project.com/index.rss";));
+                       link.Length = 0;
+                       link.Length = long.MaxValue;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void NegativeLength ()
+               {
+                       SyndicationLink link = new SyndicationLink (new Uri 
("http://mono-project.com/index.rss";));
+                       link.Length = -1;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void NegativeLength2 ()
+               {
+                       new SyndicationLink (null, null, null, null, -1);
+               }
+
+               [Test]
+               public void AttributeElementExtensions ()
+               {
+                       // The properties do not affect extension attributes.
+                       SyndicationLink link = new SyndicationLink (new Uri 
("http://mono-project.com/index.rss";));
+
+                       Assert.AreEqual (0, link.ElementExtensions.Count, "#0");
+                       Assert.IsFalse (link.AttributeExtensions.ContainsKey 
(new QName ("mediaType")), "#3");
+                       link.MediaType = "text/xml";
+               }
+
+               [Test]
+               public void GetAbsoluteUri ()
+               {
+                       // no Uri
+                       SyndicationLink link = new SyndicationLink ();
+                       Assert.IsNull (link.GetAbsoluteUri (), "#1");
+
+                       // Uri is relative
+                       link = new SyndicationLink (new Uri ("empty.xml", 
UriKind.Relative));
+                       Assert.IsNull (link.GetAbsoluteUri (), "#2");
+
+                       // Uri is absolute
+                       link = new SyndicationLink (new Uri 
("http://mono-project.com/index.rss";));
+                       Assert.AreEqual ("http://mono-project.com/index.rss";, 
link.GetAbsoluteUri ().ToString (), "#3");
+
+                       // only BaseUri - null result
+                       link = new SyndicationLink ();
+                       link.BaseUri = new Uri 
("http://mono-project.com/index.rss";);
+                       Assert.IsNull (link.GetAbsoluteUri (), "#4");
+               }
+
+               [Test]
+               public void Clone ()
+               {
+                       SyndicationLink link = new SyndicationLink (null, null, 
"my RSS", "text/xml", 1);
+                       link.BaseUri = new Uri 
("http://mono-project.com/index.rss";);
+                       SyndicationLink clone = link.Clone ();
+                       Assert.AreEqual (link.BaseUri, clone.BaseUri, "#1");
+                       Assert.AreEqual ("my RSS", clone.Title, "#2");
+                       Assert.AreEqual ("text/xml", clone.MediaType, "#3");
+                       Assert.IsNull (clone.RelationshipType, "#4");
+                       Assert.IsNull (clone.Uri, "#5");
+               }
+
+               [Test]
+               public void CreateAlternateLink ()
+               {
+                       SyndicationLink link = 
SyndicationLink.CreateAlternateLink (null);
+                       Assert.IsNull (link.Uri, "#1");
+                       Assert.IsNull (link.MediaType, "#2");
+                       Assert.AreEqual ("alternate", link.RelationshipType, 
"#3");
+               }
+
+               [Test]
+               public void CreateMediaEnclosureLink ()
+               {
+                       SyndicationLink link = 
SyndicationLink.CreateMediaEnclosureLink (null, null, 1);
+                       Assert.IsNull (link.Uri, "#1");
+                       Assert.IsNull (link.MediaType, "#2");
+                       Assert.AreEqual (1, link.Length, "#3");
+                       Assert.AreEqual ("enclosure", link.RelationshipType, 
"#4");
+               }
+
+               [Test]
+               public void CreateSelfLink ()
+               {
+                       SyndicationLink link = SyndicationLink.CreateSelfLink 
(null);
+                       Assert.IsNull (link.Uri, "#1");
+                       Assert.IsNull (link.MediaType, "#2");
+                       Assert.AreEqual ("self", link.RelationshipType, "#3");
+               }
+       }
+}


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Syndication/SyndicationLinkTest.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