Author: gonzalo
Date: 2005-09-28 03:39:08 -0400 (Wed, 28 Sep 2005)
New Revision: 50929

Added:
   trunk/mcs/class/System.Web/Test/System.Web.UI/AttributeCollectionTest.cs
Modified:
   trunk/mcs/class/System.Web/Test/System.Web.UI/ChangeLog
Log:
2005-09-28 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>

        * AttributeCollectionTest.cs: some tests for this.



Added: trunk/mcs/class/System.Web/Test/System.Web.UI/AttributeCollectionTest.cs
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI/AttributeCollectionTest.cs    
2005-09-28 05:51:10 UTC (rev 50928)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI/AttributeCollectionTest.cs    
2005-09-28 07:39:08 UTC (rev 50929)
@@ -0,0 +1,211 @@
+//
+// Tests for System.Web.UI.AttributeCollection.cs and CssStyleCollection
+//
+// Author:
+//     Gonzalo Paniagua Javier ([EMAIL PROTECTED])
+//
+//
+// Copyright (C) 2005 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 NUnit.Framework;
+using System;
+using System.IO;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+using System.Collections;
+using AC = System.Web.UI.AttributeCollection;
+
+namespace MonoTests.System.Web.UI {
+       [TestFixture]
+       public class AttributeCollectionTest {
+               [Test]
+               public void InitialNoBag1 ()
+               {
+                       AC ac = new AC (null);
+                       Assert.IsNotNull (ac.CssStyle, "style");
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void InitialNoBag2 ()
+               {
+                       AC ac = new AC (null);
+                       int i = ac.Count;
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void InitialNoBag3 ()
+               {
+                       AC ac = new AC (null);
+                       ICollection coll = ac.Keys;
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void InitialNoBag4 ()
+               {
+                       AC ac = new AC (null);
+                       string k = ac ["hola"];
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void InitialNoBag5 ()
+               {
+                       AC ac = new AC (null);
+                       ac.Add ("att", "value");
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void InitialNoBag6 ()
+               {
+                       AC ac = new AC (null);
+                       ac.Clear ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void InitialNoBag7 ()
+               {
+                       AC ac = new AC (null);
+                       HtmlTextWriter writer = new HtmlTextWriter (new 
StringWriter ());
+                       ac.AddAttributes (writer);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void InitialNoBag8 ()
+               {
+                       AC ac = new AC (null);
+                       HtmlTextWriter writer = new HtmlTextWriter (new 
StringWriter ());
+                       ac.Render (writer);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void InitialNoBag9 ()
+               {
+                       AC ac = new AC (null);
+                       ac.Remove ("hola");
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void InitialNoBag10 ()
+               {
+                       AC ac = new AC (null);
+                       CssStyleCollection css = ac.CssStyle;
+                       int i = css.Count;
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void InitialNoBag11 ()
+               {
+                       AC ac = new AC (null);
+                       CssStyleCollection css = ac.CssStyle;
+                       ICollection coll = css.Keys;
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void InitialNoBag12 ()
+               {
+                       AC ac = new AC (null);
+                       CssStyleCollection css = ac.CssStyle;
+                       string v = css ["hola"];
+               }
+
+               [Test]
+               public void InitialBag1 ()
+               {
+                       StateBag bag = new StateBag (true);
+                       AC ac = new AC (bag);
+                       Assert.AreEqual (0, ac.Count, "count");
+                       Assert.AreEqual (null, ac ["hola"], "item");
+                       Assert.AreEqual (0, ac.Keys.Count, "keys");
+                       ac.Add ("notexists", "invalid");
+                       ac.Remove ("notexists");
+                       ac.Remove ("notexists");
+
+                       HtmlTextWriter writer = new HtmlTextWriter (new 
StringWriter ());
+                       ac.AddAttributes (writer);
+                       ac.Render (writer);
+                       Assert.AreEqual (0, 
writer.InnerWriter.ToString().Length, "length");
+                       CssStyleCollection css = ac.CssStyle;
+                       Assert.AreEqual (0, css.Count, "csscount");
+                       Assert.AreEqual (null, css ["hola"], "cssitem");
+                       Assert.AreEqual (0, css.Keys.Count, "csskeys");
+                       css.Add ("notexists", "invalid");
+                       css.Remove ("notexists");
+                       css.Remove ("notexists");
+                       css.Add ("notexists", "invalid");
+                       css.Clear ();
+                       Assert.AreEqual (0, css.Keys.Count, "csskeys2");
+               }
+
+               [Test]
+               public void NonStyleAttributes1 ()
+               {
+                       StateBag bag = new StateBag (true);
+                       AC ac = new AC (bag);
+                       StringWriter sr = new StringWriter ();
+                       HtmlTextWriter writer = new HtmlTextWriter (sr);
+                       ac.Add ("notexists", "somevalue");
+                       ac.AddAttributes (writer);
+                       string str = sr.ToString ();
+                       Assert.AreEqual ("", str, "value1");
+                       Assert.AreEqual (1, bag.Count, "count1");
+                       writer = new HtmlTextWriter (sr);
+                       writer.RenderBeginTag (HtmlTextWriterTag.A);
+                       ac.AddAttributes (writer);
+                       writer.RenderEndTag ();
+                       Assert.AreEqual ("", str, "value2");
+                       Assert.AreEqual (1, bag.Count, "count2");
+               }
+
+               [Test]
+               public void NonStyleAttributes2 ()
+               {
+                       StateBag bag = new StateBag (true);
+                       AC ac = new AC (bag);
+                       StringWriter sr = new StringWriter ();
+                       HtmlTextWriter writer = new HtmlTextWriter (sr);
+                       ac.Add ("class", "classname");
+                       ac.AddAttributes (writer);
+                       string str = sr.ToString ();
+                       Assert.AreEqual ("", str, "value1");
+                       Assert.AreEqual (1, bag.Count, "count1");
+                       writer = new HtmlTextWriter (sr);
+                       writer.RenderBeginTag (HtmlTextWriterTag.A);
+                       ac.AddAttributes (writer);
+                       writer.RenderEndTag ();
+                       Assert.AreEqual ("", str, "value2");
+                       Assert.AreEqual (1, bag.Count, "count2");
+               }
+       }
+}
+


Property changes on: 
trunk/mcs/class/System.Web/Test/System.Web.UI/AttributeCollectionTest.cs
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Modified: trunk/mcs/class/System.Web/Test/System.Web.UI/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI/ChangeLog     2005-09-28 
05:51:10 UTC (rev 50928)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI/ChangeLog     2005-09-28 
07:39:08 UTC (rev 50929)
@@ -1,3 +1,7 @@
+2005-09-28 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+       * AttributeCollectionTest.cs: some tests for this.
+
 2005-09-23  Ben Maurer  <[EMAIL PROTECTED]>
 
        * HtmlTextWriterTest.cs: Reenable some stuff

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

Reply via email to