//
// HtmlTextWriterTest.cs
// - Unit tests for System.Web.UI.HtmlTextWriter
//
// Authors:
// Sebastien Pouliot
// Ben Maurer
//
// 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 System;
using System.IO;
using System.Web.UI;
using HtwTag = System.Web.UI.HtmlTextWriterTag;
using HtwAttribute = System.Web.UI.HtmlTextWriterAttribute;
using HtwStyle = System.Web.UI.HtmlTextWriterStyle;
using NUnit.Framework;
namespace MonoTests.System.Web.UI {
[TestFixture]
public class HtmlTextWriterTest {
StringWriter sw;
HtmlTextWriter w;
[SetUp]
public void SetupTests ()
{
sw = new StringWriter ();
sw.NewLine = "\n"; // Keep sanity.
w = new HtmlTextWriter (sw);
}
[Test]
public void DefaultConstFields ()
{
Assert.AreEqual ("=\"", HtmlTextWriter.EqualsDoubleQuoteString, "EqualsDoubleQuoteString");
// add more
}
[Test]
public void NullWriter ()
{
HtmlTextWriter htw = new HtmlTextWriter (null);
Assert.IsNotNull (htw, "NullWriter");
Assert.IsNull (htw.InnerWriter, "InnerWriter");
}
[Test]
public void WriteAttributes_NullValue ()
{
w.WriteAttribute ("name", null);
Assert.AreEqual (" name", w.InnerWriter.ToString ());
}
[Test]
public void Write1 ()
{
w.RenderBeginTag ("a");
w.RenderEndTag ();
Assert.AreEqual ("", sw.ToString ());
}
[Test]
public void WriteATagByKey ()
{
w.RenderBeginTag (HtwTag.A);
w.RenderEndTag ();
Assert.AreEqual ("", sw.ToString ());
}
[Test]
public void WriteDivTagByKey ()
{
w.RenderBeginTag (HtwTag.Div);
w.RenderEndTag ();
Assert.AreEqual ("