Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,356 @@
2010-06-21 Marek Habersack <mhabersack@novell.com>
* HtmlImageTest.cs: fixed an invalid test.
2009-07-06 Raja R Harinath <harinath@hurrynot.org>
* HtmlFormTest.cs: Derive from SystemWebTestShim.Page to make
explicit the dependence on the internals of the Page class.
2008-11-07 Marek Habersack <mhabersack@novell.com>
* HtmlFormTest.cs: added a test for the undocumented Action
property.
2008-10-07 Christian Hergert <christian.hergert@gmail.com>
* HtmlImageTest.cs: Add test to make sure the src attribute is not
rendered when it is empty.
2008-07-27 Dean Brettle <dean@brettle.com>
* HtmlInputButtonTest.cs, HtmlImageTest.cs, HtmlFormTest.cs,
HtmlInputRadioButtonTest.cs, HtmlSelectTest.cs: Added tests
for HTML-encoded of attributes.
2008-06-08 Gert Driesen <drieseng@users.sourceforge.net>
* HtmlAnchorTest.cs: Added RenderAttributes tests for empty or null
HRef, Name, Target and Title.
2008-05-04 Igor Zelmanovich <igorz@mainsoft.com>
* HtmlInputButtonTest.cs: use HtmlDiff properly.
2008-04-03 Marek Habersack <mhabersack@novell.com>
* HtmlFormTest.cs: indirect test for bug #376352 is 2.0+ only.
2008-04-02 Marek Habersack <mhabersack@novell.com>
* HtmlFormTest.cs: added an indirect test for bug #376352
(HttpRequest.QueryStringRaw internal property) - Mono only.
2008-01-31 Igor Zelmanovich <igorz@mainsoft.com>
* HtmlInputControlTest.cs:
* HtmlTextAreaTest.cs:
fix tests - use valid xml with HtmlDiff.AssertAreEqual API.
2007-07-31 Vladimir Krasnov <vladimirk@mainsoft.com>
* HtmlImageTest.cs: fixed RenderAttributes, moved to webtest since src
attribute must be resolved
2007-01-04 Adar Wesley <adarw@mainsoft.com>
* HtmlSelectTest.cs: updated tests to use HtmlDiff
2006-11-13 Igor Zelmanovich <igorz@mainsoft.com>
* HtmlContainerControlTest.cs: added new tests
2006-09-17 Igor Zelmanovich <igorz@mainsoft.com>
* HtmlAnchorTest.cs: added test for ViewState
2006-07-10 Andrew Skiba <andrews@mainsoft.com>
* HtmlInputControlTest.cs: check attribute values, not only their
count.
2006-04-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* HtmlInputRadioButtonTest.cs: added test for bug #78101.
2005-11-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* HtmlTextAreaTest.cs: add new test for 'Name'.
2005-11-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* HtmlTableTest.cs: remove white-space characters when comparing
the output.
2005-11-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* HtmlInputButtonTest.cs: more tests for 'onclick'.
2005-09-29 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* HtmlFormTest.cs: Trim() the rendered form when comparing (\n vs \r\n).
2005-09-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* HtmlInputButtonTest.cs: make sure the onclick attribute is rendered
when we have a ServerClick event registered.
2005-09-19 Sebastien Pouliot <sebastien@ximian.com>
* HtmlAnchorCas.cs: Added "normal" unit tests execution under Deny
Unrestricted.
* HtmlAnchorTest.cs: RaisePostBackEvent now throws a NRE under 2.0 RC.
* HtmlButtonCas.cs: Added "normal" unit tests execution under Deny
Unrestricted.
* HtmlContainerControlCas.cs: New. CAS unit tests.
* HtmlFormCas.cs: Added "normal" unit tests execution under Deny
Unrestricted.
* HtmlFormTest.cs: Fixed rendering output under 2.0 RC.
* HtmlImageCas.cs: Added "normal" unit tests execution under Deny
Unrestricted.
* HtmlInputButtonCas.cs: Added "normal" unit tests execution under
Deny Unrestricted.
* HtmlInputButtonTest.cs: Fixed attribute count for 2.0 RC.
* HtmlInputControlCas.cs: New. CAS unit tests.
* HtmlInputControlTest.cs: Fixed attribute count for 2.0 RC.
* HtmlInputCheckBoxCas.cs: Added "normal" unit tests execution under
Deny Unrestricted.
* HtmlInputCheckBoxTest.cs: Fixed attribute count for 2.0 RC (which is
now identical to 1.x results).
* HtmlInputFileCas.cs: Added "normal" unit tests execution under Deny
Unrestricted.
* HtmlInputFileTest.cs: Fixed attribute count for 2.0 RC.
* HtmlInputHiddenCas.cs: Fixed attribute count for 2.0 RC.
* HtmlInputPasswordCas.cs: Added "normal" unit tests execution under
Deny Unrestricted.
* HtmlInputPasswordTest.cs: Adjusted tests as 2.0 RC removed the
ctor(string).
* HtmlInputRadioButtonCas.cs: Fixed attribute count for 2.0 RC.
* HtmlInputRadioButtonTest.cs: Added "normal" unit tests execution
under Deny Unrestricted.
* HtmlInputResetCas.cs: Added "normal" unit tests execution under Deny
Unrestricted.
* HtmlInputResetTest.cs: Fixed attribute count for 2.0 RC.
* HtmlInputSubmitCas.cs: Added "normal" unit tests execution under
Deny Unrestricted.
* HtmlInputSubmitTest.cs: Fixed attribute count for 2.0 RC.
* HtmlInputTextCas.cs: Added "normal" unit tests execution under Deny
Unrestricted.
* HtmlInputTextTest.cs: Fixed attribute count for 2.0 RC.
* HtmlLinkCas.cs: New. CAS unit tests.
* HtmlMetaCas.cs: New. CAS unit tests.
* HtmlMetaTest.cs: Fixed rendering for 2.0 RC (tag ending).
* HtmlSelectCas.cs: Added "normal" unit tests execution under Deny
Unrestricted.
* HtmlTableCas.cs: Added "normal" unit tests execution under Deny
Unrestricted.
* HtmlTableCellCas.cs: Added "normal" unit tests execution under Deny
Unrestricted.
* HtmlTableRowCas.cs: Added "normal" unit tests execution under Deny
Unrestricted.
* HtmlTextAreaCas.cs: New. CAS unit tests.
2005-09-13 Sebastien Pouliot <sebastien@ximian.com>
* HtmlInputTextTest.cs: Fix expected value for LoadPostData (in the
cases where MS returns a NullReferenceException).
2005-09-11 Chris Toshok <toshok@ximian.com>
* HtmlInputFileTest.cs (Attribute_Count): fix for 2.0.
2005-09-11 Chris Toshok <toshok@ximian.com>
* HtmlInputFileTest.cs: new tests.
2005-09-09 Chris Toshok <toshok@ximian.com>
* HtmlFormTest.cs: Add test for RenderChildren.
2005-09-09 Chris Toshok <toshok@ximian.com>
* HtmlInputButtonTest.cs (RenderAttributes): add in
CausesValidation and ValidationGroup here.
2005-09-09 Sebastien Pouliot <sebastien@ximian.com>
* HtmlTableRowTest.cs: Added tests for InnerHtml and InnerText setters
* HtmlTableTest.cs: Added tests for InnerHtml and InnerText setters
2005-09-07 Chris Toshok <toshok@ximian.com>
* HtmlFormTest.cs: more tests to get at the root of the confusion
that is the Name property. Also, copy over Gonzalo's
Name_InsideNaming from HtmlInputControlTest.cs here.
2005-09-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* HtmlInputControlTest.cs: new tests for the case when the control is
inside a different naming container.
2005-09-06 Chris Toshok <toshok@ximian.com>
* HtmlLinkTest.cs: add empty render test.
* HtmlMetaTest.cs: same.
2005-09-06 Chris Toshok <toshok@ximian.com>
* HtmlLinkTest.cs: new tests.
* HtmlMetaTest.cs: new tests.
2005-09-05 Chris Toshok <toshok@ximian.com>
* HtmlFormTest.cs: add some more tests to make figure out the
property spot to be storing some of these attributes.
2005-09-01 Sebastien Pouliot <sebastien@ximian.com>
* HtmlAnchorCas.cs, HtmlButtonCas.cs, HtmlEmptyTagControlBuilderCas.cs,
HtmlFormCas.cs, HtmlGenericControlCas.cs, HtmlHeadBuilderCas.cs,
HtmlHeadCas.cs, HtmlImageCas.cs, HtmlInputButtonCas.cs,
HtmlInputCheckBoxCas.cs, HtmlInputFileCas.cs, HtmlInputHiddenCas.cs,
HtmlInputImageCas.cs, HtmlInputPasswordCas.cs,
HtmlInputRadioButtonCas.cs, HtmlInputResetCas.cs,
HtmlInputSubmitCas.cs, HtmlInputTextCas.cs, HtmlSelectBuilderCas.cs,
HtmlSelectCas.cs, HtmlTableCas.cs, HtmlTableCellCas.cs.
HtmlTableRowCas.cs, HtmlTitleCas.cs: New. CAS unit tests to check for
AspNetHostingPermission Level.
2005-08-29 Chris Toshok <toshok@ximian.com>
* HtmlInputSubmitTest.cs: new, base-level tests.
* HtmlInputButtonTest.cs: add CausesValidation/ValidationGroup
view state tests.
2005-08-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* HtmlAnchorTest.cs: add test for HRef with an absolute URI.
2005-08-28 Chris Toshok <toshok@ximian.com>
* HtmlInputResetTest.cs: new tests for HtmlInputReset. Missing
event tests.
2005-08-28 Chris Toshok <toshok@ximian.com>
* HtmlInputPasswordTest.cs: new tests for HtmlInputPassword.
2005-08-26 Sebastien Pouliot <sebastien@ximian.com>
* HtmlButtonTest.cs: Fix 1.1 build. ValidationGroup is only present in
the 2.0 profile.
2005-08-26 Chris Toshok <toshok@ximian.com>
* HtmlButtonTest.cs: add view state tests (to make sure
ValidationGroup and CausesValidation are there.)
2005-08-22 Chris Toshok <toshok@ximian.com>
* HtmlInputCheckBoxTest.cs: 2.0-ify these tests.
* HtmlInputButtonTest.cs: same.
2005-08-15 Sebastien Pouliot <sebastien@ximian.com>
* HtmlAnchorTest.cs: Added test cases for IPostBackEventHandler (in
1.x) and for protected RaisePostBackEvent (in 2.0).
* HtmlInputControlTest.cs: Added test to ensure HtmlInputRadioButton's
Value behaviour wasn't inherited.
* HtmlInputTextTest.cs: Added test cases for IPostBackDataHandler (in
1.x) and for new protected LoadPostData and RaisePostDataChangedEvent
methods (in 2.0).
* HtmlInputRadioButtonTest.cs: Added test cases for Value property and
it's relattion to ID. Added tests cases for IPostBackDataHandler (in
1.x) and for new protected LoadPostData and RaisePostDataChangedEvent
methods (in 2.0).
* HtmlTextAreaTest.cs: Added test cases for IPostBackDataHandler (in
1.x) and for new protected LoadPostData and RaisePostDataChangedEvent
methods (in 2.0).
2005-08-08 Sebastien Pouliot <sebastien@ximian.com>
* HtmlInputControlTest.cs: Added a new test to see if the value
removal for type==password was done at this level (it's not).
* HtmlInputTextTest.cs: Fixed tests to execute without failure on both
1.1 SP1 and 2.0 beta 2.
2005-07-27 Dick Porter <dick@ximian.com>
* HtmlInputCheckBoxTest.cs: Tests for HtmlInputCheckBox
2005-07-26 Dick Porter <dick@ximian.com>
* HtmlSelectTest.cs: Tests for HtmlSelect
2005-07-21 Dick Porter <dick@ximian.com>
* HtmlImageTest.cs: The order of attribute rendering has changed,
and now matches MS
2005-07-19 Dick Porter <dick@ximian.com>
* HtmlImageTest.cs: Added tests for negative values in int
properties
2005-07-18 Sebastien Pouliot <sebastien@ximian.com>
* HtmlInputControlTest.cs: Added a test when using null in the ctor
(type is empty, not null). Test UniqueID, not only ID, when changing
the Name property.
2005-07-18 Jackson Harper <jackson@ximian.com>
* HtmlInputHiddenTest.cs: New test.
2005-07-15 Sebastien Pouliot <sebastien@ximian.com>
* HtmlAnchorTest.cs: Added tests for resolving the URL and the
mysterious disappearance of the HRef attribute after rendering.
2005-07-14 Jackson Harper <jackson@ximian.com>
* HtmlInputButton.cs: New tests for HtmlInputButton.
2005-07-14 Jackson Harper <jackson@ximian.com>
* HtmlButtonTest.cs: New tests for HtmlButton.
2005-07-14 Dick Porter <dick@ximian.com>
* HtmlFormTest.cs: New set of tests
2005-07-08 Sebastien Pouliot <sebastien@ximian.com>
* HtmlTextAreaTest.cs: Added checks to see that Attributes are moved
into the StateView.
2005-07-08 Sebastien Pouliot <sebastien@ximian.com>
* HtmlContainerControlTest.cs: Unit tests for HtmlContainerControl.
Basically to check for removal of attributes/viewstate informations.
* HtmlTextAreaTest.cs: Unit tests for HtmlTextArea.
2005-07-07 Sebastien Pouliot <sebastien@ximian.com>
* HtmlInputRadioButtonTest.cs: Unit tests for HtmlInputRadioButton.
* HtmlInputTextTest.cs: More tests to check for password erasure fu.
2005-07-07 Sebastien Pouliot <sebastien@ximian.com>
* HtmlInputControlTest.cs: Unit tests for HtmlInputControl.
* HtmlInputTextTest.cs: Unit tests for HtmlInputText.
2005-07-07 Dick Porter <dick@ximian.com>
* HtmlImageTest.cs: Unit tests for HtmlImage
2005-07-07 Sebastien Pouliot <sebastien@ximian.com>
* HtmlAnchorTest.cs: Unit tests for HtmlAnchor.
* HtmlTableTest.cs: Unit tests for HtmlTable.
* HtmlTableCellTest.cs: Unit tests for HtmlTableCell.
* HtmlTableRowTest.cs: Unit tests for HtmlTableRow.

View File

@@ -0,0 +1,64 @@
//
// HtmlAnchorCas.cs - CAS unit tests for System.Web.UI.HtmlControls.HtmlAnchor
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// 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.Security.Permissions;
using System.Web.UI.HtmlControls;
using MonoTests.System.Web.UI.HtmlControls;
namespace MonoCasTests.System.Web.UI.HtmlControls {
[TestFixture]
[Category ("CAS")]
public class HtmlAnchorCas : AspNetHostingMinimal {
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Deny_Unrestricted ()
{
HtmlAnchorTest unit = new HtmlAnchorTest ();
unit.DefaultProperties ();
unit.NullProperties ();
unit.Target ();
unit.HRef ();
unit.AbsoluteHRef ();
unit.RenderAttributes ();
#if ONLY_1_1
// sadly this started to throw NRE in 2.0 RC
unit.IPostBackEventHandler_RaisePostBackEvent ();
#endif
}
public override Type Type {
get { return typeof (HtmlAnchor); }
}
}
}

View File

@@ -0,0 +1,346 @@
//
// HtmlAnchorTest.cs
// - Unit tests for System.Web.UI.HtmlControls.HtmlAnchor
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// 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 System.Web.UI.HtmlControls;
using NUnit.Framework;
namespace MonoTests.System.Web.UI.HtmlControls {
public class TestHtmlAnchor : HtmlAnchor {
public HtmlTextWriter GetWriter ()
{
StringWriter text = new StringWriter ();
HtmlTextWriter writer = new HtmlTextWriter (text);
base.RenderAttributes (writer);
return writer;
}
#if NET_2_0
public void Raise ()
{
base.RaisePostBackEvent ("2.0");
}
#endif
public void TrakState () {
TrackViewState();
}
public object SaveState () {
return SaveViewState ();
}
public void LoadState (object state) {
LoadViewState (state);
}
}
[TestFixture]
public class HtmlAnchorTest {
[Test]
public void DefaultProperties ()
{
HtmlAnchor a = new HtmlAnchor ();
Assert.AreEqual (0, a.Attributes.Count, "Attributes.Count");
Assert.AreEqual (String.Empty, a.HRef, "HRef");
Assert.AreEqual (String.Empty, a.Name, "Name");
Assert.AreEqual (String.Empty, a.Target, "Target");
Assert.AreEqual (String.Empty, a.Title, "Title");
Assert.AreEqual ("a", a.TagName, "TagName");
}
[Test]
public void NullProperties ()
{
HtmlAnchor a = new HtmlAnchor ();
a.HRef = null;
Assert.AreEqual (String.Empty, a.HRef, "HRef");
a.Name = null;
Assert.AreEqual (String.Empty, a.Name, "Name");
a.Target = null;
Assert.AreEqual (String.Empty, a.Target, "Target");
a.Title = null;
Assert.AreEqual (String.Empty, a.Title, "Title");
Assert.AreEqual (0, a.Attributes.Count, "Attributes.Count");
}
[Test]
public void Target ()
{
HtmlAnchor a = new HtmlAnchor ();
// specials (various casing)
a.Target = "_blank";
Assert.AreEqual ("_blank", a.Target, "_blank");
a.Target = "_parent";
Assert.AreEqual ("_parent", a.Target, "_parent");
a.Target = "_SELF";
Assert.AreEqual ("_SELF", a.Target, "_SELF");
a.Target = "_ToP";
Assert.AreEqual ("_ToP", a.Target, "_ToP");
// alpha
a.Target = "a";
Assert.AreEqual ("a", a.Target, "a");
a.Target = "blank";
Assert.AreEqual ("blank", a.Target, "blank");
a.Target = "Z";
Assert.AreEqual ("Z", a.Target, "Z");
}
[Test]
public void Target_Invalid ()
{
HtmlAnchor a = new HtmlAnchor ();
// non alpha
a.Target = "9a";
Assert.AreEqual ("9a", a.Target, "9a");
// non special
a.Target = "_mono";
Assert.AreEqual ("_mono", a.Target, "_mono");
}
[Test]
public void HRef ()
{
TestHtmlAnchor a = new TestHtmlAnchor ();
a.HRef = "~/otherfile.txt";
Assert.AreEqual ("~/otherfile.txt", a.HRef, "HRef");
// resolve doesn't apply on the property
}
[Test]
public void RenderAttributes ()
{
TestHtmlAnchor a = new TestHtmlAnchor ();
a.HRef = "*1*";
a.Name = "*2*";
a.Target = "*3*";
a.Title = "*4*";
Assert.AreEqual (4, a.Attributes.Count, "Attributes.Count/4");
HtmlTextWriter writer = a.GetWriter ();
Assert.AreEqual (" href=\"*1*\" name=\"*2*\" target=\"*3*\" title=\"*4*\"", writer.InnerWriter.ToString (), "attributes");
// HRef is missing, from the attributes collection, after rendering
Assert.AreEqual (3, a.Attributes.Count, "Attributes.Count/3");
Assert.AreEqual (String.Empty, a.HRef, "HRef");
// but href is still rendered
Assert.AreEqual (" href=\"*1*\" name=\"*2*\" target=\"*3*\" title=\"*4*\"", writer.InnerWriter.ToString (), "HRef is back");
}
[Test]
public void RenderAttributes_HRef_Empty ()
{
TestHtmlAnchor a = new TestHtmlAnchor ();
Assert.AreEqual (0, a.Attributes.Count, "#1");
a.HRef = string.Empty;
a.Name = "*2*";
a.Target = "*3*";
a.Title = "*4*";
Assert.AreEqual (3, a.Attributes.Count, "#2");
HtmlTextWriter writer = a.GetWriter ();
Assert.AreEqual (" name=\"*2*\" target=\"*3*\" title=\"*4*\"", writer.InnerWriter.ToString (), "#3");
}
[Test]
public void RenderAttributes_HRef_Null ()
{
TestHtmlAnchor a = new TestHtmlAnchor ();
Assert.AreEqual (0, a.Attributes.Count, "#1");
a.HRef = null;
a.Name = "*2*";
a.Target = "*3*";
a.Title = "*4*";
Assert.AreEqual (3, a.Attributes.Count, "#2");
HtmlTextWriter writer = a.GetWriter ();
Assert.AreEqual (" name=\"*2*\" target=\"*3*\" title=\"*4*\"", writer.InnerWriter.ToString (), "#3");
}
[Test]
public void RenderAttributes_Name_Empty ()
{
TestHtmlAnchor a = new TestHtmlAnchor ();
Assert.AreEqual (0, a.Attributes.Count, "#1");
a.HRef = "*1*";
a.Name = string.Empty;
a.Target = "*3*";
a.Title = "*4*";
Assert.AreEqual (3, a.Attributes.Count, "#2");
HtmlTextWriter writer = a.GetWriter ();
Assert.AreEqual (" href=\"*1*\" target=\"*3*\" title=\"*4*\"", writer.InnerWriter.ToString (), "#3");
}
[Test]
public void RenderAttributes_Name_Null ()
{
TestHtmlAnchor a = new TestHtmlAnchor ();
Assert.AreEqual (0, a.Attributes.Count, "#1");
a.HRef = "*1*";
a.Name = null;
a.Target = "*3*";
a.Title = "*4*";
Assert.AreEqual (3, a.Attributes.Count, "#2");
HtmlTextWriter writer = a.GetWriter ();
Assert.AreEqual (" href=\"*1*\" target=\"*3*\" title=\"*4*\"", writer.InnerWriter.ToString (), "#3");
}
[Test]
public void RenderAttributes_Target_Empty ()
{
TestHtmlAnchor a = new TestHtmlAnchor ();
Assert.AreEqual (0, a.Attributes.Count, "#1");
a.HRef = "*1*";
a.Name = "*2*";
a.Target = string.Empty;
a.Title = "*4*";
Assert.AreEqual (3, a.Attributes.Count, "#2");
HtmlTextWriter writer = a.GetWriter ();
Assert.AreEqual (" href=\"*1*\" name=\"*2*\" title=\"*4*\"", writer.InnerWriter.ToString (), "#3");
}
[Test]
public void RenderAttributes_Target_Null ()
{
TestHtmlAnchor a = new TestHtmlAnchor ();
Assert.AreEqual (0, a.Attributes.Count, "#1");
a.HRef = "*1*";
a.Name = "*2*";
a.Target = null;
a.Title = "*4*";
Assert.AreEqual (3, a.Attributes.Count, "#2");
HtmlTextWriter writer = a.GetWriter ();
Assert.AreEqual (" href=\"*1*\" name=\"*2*\" title=\"*4*\"", writer.InnerWriter.ToString (), "#3");
}
[Test]
public void RenderAttributes_Title_Empty ()
{
TestHtmlAnchor a = new TestHtmlAnchor ();
Assert.AreEqual (0, a.Attributes.Count, "#1");
a.HRef = "*1*";
a.Name = "*2*";
a.Target = "*3*";
a.Title = string.Empty;
Assert.AreEqual (3, a.Attributes.Count, "#2");
HtmlTextWriter writer = a.GetWriter ();
Assert.AreEqual (" href=\"*1*\" name=\"*2*\" target=\"*3*\"", writer.InnerWriter.ToString (), "#3");
}
[Test]
public void RenderAttributes_Title_Null ()
{
TestHtmlAnchor a = new TestHtmlAnchor ();
Assert.AreEqual (0, a.Attributes.Count, "#1");
a.HRef = "*1*";
a.Name = "*2*";
a.Target = "*3*";
a.Title = null;
Assert.AreEqual (3, a.Attributes.Count, "#2");
HtmlTextWriter writer = a.GetWriter ();
Assert.AreEqual (" href=\"*1*\" name=\"*2*\" target=\"*3*\"", writer.InnerWriter.ToString (), "#3");
}
private bool serverClick;
private void ServerClick (object sender, EventArgs e)
{
serverClick = true;
}
[Test]
#if NET_2_0
[ExpectedException (typeof (NullReferenceException))] // since 2.0 RC :-(
#endif
public void IPostBackEventHandler_RaisePostBackEvent ()
{
TestHtmlAnchor a = new TestHtmlAnchor ();
a.ServerClick += new EventHandler (ServerClick);
IPostBackEventHandler pbeh = (a as IPostBackEventHandler);
serverClick = false;
pbeh.RaisePostBackEvent ("mono");
Assert.IsTrue (serverClick, "ServerClick");
}
[Test]
public void AbsoluteHRef ()
{
TestHtmlAnchor a = new TestHtmlAnchor ();
a.HRef = "http://127.0.0.1/";
HtmlTextWriter writer = a.GetWriter ();
Assert.AreEqual (" href=\"http://127.0.0.1/\"", writer.InnerWriter.ToString (), "#01");
}
#if NET_2_0
[Test]
[ExpectedException (typeof (NullReferenceException))] // since 2.0 RC :-(
public void RaisePostBackEvent ()
{
TestHtmlAnchor a = new TestHtmlAnchor ();
a.ServerClick += new EventHandler (ServerClick);
serverClick = false;
a.Raise ();
Assert.IsTrue (serverClick, "ServerClick");
}
[Test]
public void ViewState2 () {
TestHtmlAnchor a = new TestHtmlAnchor ();
a.TrakState ();
a.CausesValidation = false;
a.ValidationGroup = "VG";
object s = a.SaveState ();
TestHtmlAnchor copy = new TestHtmlAnchor ();
copy.LoadState (s);
Assert.AreEqual (false, copy.CausesValidation, "A1");
Assert.AreEqual ("VG", copy.ValidationGroup, "A2");
}
#endif
}
}

View File

@@ -0,0 +1,58 @@
//
// HtmlButtonCas.cs - CAS unit tests for System.Web.UI.HtmlControls.HtmlButton
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// 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.Security.Permissions;
using System.Web.UI.HtmlControls;
using MonoTests.System.Web.UI.HtmlControls;
namespace MonoCasTests.System.Web.UI.HtmlControls {
[TestFixture]
[Category ("CAS")]
public class HtmlButtonCas : AspNetHostingMinimal {
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Deny_Unrestricted ()
{
HtmlButtonTest unit = new HtmlButtonTest ();
unit.Defaults ();
unit.CleanProperties ();
unit.ViewState ();
unit.RenderAttributes ();
}
public override Type Type {
get { return typeof (HtmlButton); }
}
}
}

View File

@@ -0,0 +1,135 @@
//
// HtmlButtonTest.cs
// - Unit tests for System.Web.UI.HtmlControls.HtmlButton
//
// Author:
// Jackson Harper (jackson@ximian.com)
//
// 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 System.Web.UI.HtmlControls;
using NUnit.Framework;
namespace MonoTests.System.Web.UI.HtmlControls {
public class HtmlButtonPoker : HtmlButton {
public HtmlButtonPoker ()
{
TrackViewState ();
}
public object SaveState ()
{
return SaveViewState ();
}
public void LoadState (object state)
{
LoadViewState (state);
}
public void DoRenderAttributes (HtmlTextWriter writer)
{
RenderAttributes (writer);
}
}
[TestFixture]
public class HtmlButtonTest {
[Test]
public void Defaults ()
{
HtmlButtonPoker p = new HtmlButtonPoker ();
Assert.IsTrue (p.CausesValidation, "A1");
#if NET_2_0
Assert.AreEqual ("", p.ValidationGroup, "A2");
#endif
}
[Test]
public void CleanProperties ()
{
HtmlButtonPoker p = new HtmlButtonPoker ();
p.CausesValidation = false;
Assert.IsFalse (p.CausesValidation, "A1");
p.CausesValidation = true;
Assert.IsTrue (p.CausesValidation, "A2");
p.CausesValidation = false;
Assert.IsFalse (p.CausesValidation, "A3");
}
[Test]
public void ViewState ()
{
HtmlButtonPoker p = new HtmlButtonPoker ();
p.CausesValidation = true;
#if NET_2_0
p.ValidationGroup = "VG";
#endif
object state = p.SaveState();
HtmlButtonPoker copy = new HtmlButtonPoker ();
copy.LoadState (state);
#if NET_2_0
Assert.AreEqual ("VG", copy.ValidationGroup, "A1");
#endif
Assert.IsTrue (copy.CausesValidation, "A2");
}
[Test]
public void RenderAttributes ()
{
StringWriter sw = new StringWriter ();
HtmlTextWriter tw = new HtmlTextWriter (sw);
HtmlButtonPoker p = new HtmlButtonPoker ();
Assert.AreEqual (p.Attributes.Count, 0, "A1");
p.DoRenderAttributes (tw);
Assert.AreEqual (sw.ToString (), String.Empty, "A2");
p.ServerClick += new EventHandler (EmptyHandler);
p.DoRenderAttributes (tw);
// This is empty because the control doesn't have
// its Page property initialized
Assert.AreEqual (sw.ToString (), String.Empty, "A3");
}
private static void EmptyHandler (object sender, EventArgs e)
{
}
}
}

View File

@@ -0,0 +1,66 @@
//
// HtmlContainerControlCas.cs
// - CAS unit tests for System.Web.UI.HtmlControls.HtmlContainerControl
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// 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.Security;
using System.Security.Permissions;
using System.Web.UI.HtmlControls;
using MonoTests.System.Web.UI.HtmlControls;
namespace MonoCasTests.System.Web.UI.HtmlControls {
[TestFixture]
[Category ("CAS")]
public class HtmlContainerControlCas {
// note: we do not inherit from AspNetHostingMinimal because
// HtmlContainerControl is an abstract class
[SetUp]
public virtual void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Deny_Unrestricted ()
{
HtmlContainerControlTest unit = new HtmlContainerControlTest ();
unit.DefaultProperties ();
unit.NullProperties ();
unit.CleanProperties ();
unit.Render ();
}
}
}

View File

@@ -0,0 +1,147 @@
//
// HtmlContainerControlTest.cs
// - Unit tests for System.Web.UI.HtmlControls.HtmlContainerControl
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// 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;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using NUnit.Framework;
namespace MonoTests.System.Web.UI.HtmlControls {
public class TestHtmlContainerControl : HtmlContainerControl {
public string Render ()
{
HtmlTextWriter writer = new HtmlTextWriter (new StringWriter ());
base.Render (writer);
return writer.InnerWriter.ToString ();
}
}
[TestFixture]
public class HtmlContainerControlTest {
[Test]
public void DefaultProperties ()
{
TestHtmlContainerControl cc = new TestHtmlContainerControl ();
Assert.AreEqual (0, cc.Attributes.Count, "Attributes.Count");
Assert.AreEqual (String.Empty, cc.InnerHtml, "InnerHtml");
Assert.AreEqual (String.Empty, cc.InnerText, "InnerText");
Assert.AreEqual ("span", cc.TagName, "TagName");
Assert.AreEqual (0, cc.Attributes.Count, "Attributes.Count-2");
}
[Test]
public void InnerText () {
HtmlButton c = new HtmlButton ();
DataBoundLiteralControl db = new DataBoundLiteralControl (1, 0);
db.SetStaticString (0, "FFF");
c.Controls.Add (db);
Assert.AreEqual ("FFF", c.InnerText);
}
[Test]
[ExpectedException (typeof (HttpException))]
public void InnerText2 () {
HtmlButton c = new HtmlButton ();
DesignerDataBoundLiteralControl x = new DesignerDataBoundLiteralControl ();
x.Text = "FFF";
c.Controls.Add (x);
string s = c.InnerText;
}
[Test]
public void InnerText3 () {
HtmlButton c = new HtmlButton ();
LiteralControl x = new LiteralControl ();
x.Text = "FFF";
c.Controls.Add (x);
Assert.AreEqual("FFF", c.InnerText);
}
[Test]
[ExpectedException (typeof (HttpException))]
public void InnerText4 () {
HtmlButton c = new HtmlButton ();
LiteralControl x = new LiteralControl ();
x.Text = "FFF";
c.Controls.Add (x);
LiteralControl x2 = new LiteralControl ();
x2.Text = "BBB";
c.Controls.Add (x2);
string s = c.InnerText;
}
[Test]
public void NullProperties ()
{
TestHtmlContainerControl cc = new TestHtmlContainerControl ();
cc.InnerHtml = null;
Assert.AreEqual (String.Empty, cc.InnerHtml, "InnerHtml");
cc.InnerText = null;
Assert.AreEqual (String.Empty, cc.InnerText, "InnerText");
Assert.AreEqual (0, cc.Attributes.Count, "Attributes.Count");
}
[Test]
public void CleanProperties ()
{
TestHtmlContainerControl cc = new TestHtmlContainerControl ();
cc.InnerHtml = "mono";
Assert.AreEqual ("mono", cc.InnerHtml, "InnerHtml");
Assert.AreEqual ("mono", cc.InnerText, "InnerText");
cc.InnerText = "go mono";
Assert.AreEqual ("go mono", cc.InnerHtml, "InnerHtml");
Assert.AreEqual ("go mono", cc.InnerText, "InnerText");
cc.InnerHtml = null;
Assert.AreEqual (String.Empty, cc.InnerHtml, "InnerHtml");
cc.InnerText = null;
Assert.AreEqual (String.Empty, cc.InnerText, "InnerText");
Assert.AreEqual (0, cc.Attributes.Count, "Attributes.Count");
}
[Test]
public void Render ()
{
TestHtmlContainerControl cc = new TestHtmlContainerControl ();
cc.InnerHtml = "mono";
Assert.AreEqual ("<span>mono</span>", cc.Render ());
}
}
}

View File

@@ -0,0 +1,49 @@
//
// HtmlEmptyTagControlBuilderCas.cs - CAS unit tests for
// System.Web.UI.HtmlControls.HtmlEmptyTagControlBuilder
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Web.UI.HtmlControls;
namespace MonoCasTests.System.Web.UI.HtmlControls {
[TestFixture]
[Category ("CAS")]
public class HtmlEmptyTagControlBuilderCas : AspNetHostingMinimal {
public override Type Type {
get { return typeof (HtmlEmptyTagControlBuilder); }
}
}
}
#endif

View File

@@ -0,0 +1,63 @@
//
// HtmlFormCas.cs - CAS unit tests for System.Web.UI.HtmlControls.HtmlForm
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// 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.Security.Permissions;
using System.Web.UI.HtmlControls;
using MonoTests.System.Web.UI.HtmlControls;
namespace MonoCasTests.System.Web.UI.HtmlControls {
[TestFixture]
[Category ("CAS")]
public class HtmlFormCas : AspNetHostingMinimal {
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Deny_Unrestricted ()
{
HtmlFormTest unit = new HtmlFormTest ();
unit.DefaultProperties ();
unit.NullProperties ();
unit.Attributes ();
unit.ViewState ();
unit.Name_InsideNaming ();
unit.RenderChildren ();
#if NET_2_0
unit.ControlCollection ();
#endif
}
public override Type Type {
get { return typeof (HtmlForm); }
}
}
}

View File

@@ -0,0 +1,314 @@
//
// HtmlFormTest.cs
// - Unit tests for System.Web.UI.HtmlControls.HtmlForm
//
// Author:
// Dick Porter <dick@ximian.com>
//
// 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.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using MonoTests.stand_alone.WebHarness;
using NUnit.Framework;
namespace MonoTests.System.Web.UI.HtmlControls {
class TestPage : SystemWebTestShim.Page {
private HttpContext ctx;
// don't call base class (so _context is never set to a non-null value)
protected internal override HttpContext Context {
get {
if (ctx == null) {
ctx = new HttpContext (
new HttpRequest ("default.aspx", "http://mono-project.com/", "q=1&q2=2"),
new HttpResponse (new StringWriter ())
);
}
return ctx;
}
}
#if NET_2_0 && !TARGET_JVM
public void SetContext ()
{
SetContext (Context);
}
#endif
}
public class FormPoker : HtmlForm {
public FormPoker () {
TrackViewState ();
}
public object SaveState ()
{
return SaveViewState ();
}
public void LoadState (object state)
{
LoadViewState (state);
}
/* Not called at all when running the current tests (2005/09/29)
protected override void OnInit (EventArgs e)
{
Console.WriteLine (Environment.StackTrace);
base.OnInit (e);
}
*/
public string RenderChildren ()
{
StringWriter sw = new StringWriter();
HtmlTextWriter w = new HtmlTextWriter (sw);
RenderChildren (w);
return sw.ToString();
}
public string RenderAttributes ()
{
StringWriter sw = new StringWriter();
HtmlTextWriter w = new HtmlTextWriter (sw);
RenderAttributes (w);
return sw.ToString ();
}
#if NET_2_0
public ControlCollection GetControlCollection ()
{
return CreateControlCollection();
}
#endif
}
class FUControl : UserControl {
}
[TestFixture]
public class HtmlFormTest {
[Test]
public void DefaultProperties ()
{
HtmlForm form = new HtmlForm ();
Assert.AreEqual (0, form.Attributes.Count, "Attributes.Count");
Assert.AreEqual (String.Empty, form.Enctype, "Enctype");
Assert.AreEqual ("post", form.Method, "Method");
Assert.AreEqual (form.UniqueID, form.Name, "Name");
Assert.AreEqual (String.Empty, form.Target, "Target");
Assert.AreEqual ("form", form.TagName, "TagName");
#if NET_2_0
Assert.IsFalse (form.SubmitDisabledControls, "TagName");
#endif
}
[Test]
public void NullProperties ()
{
HtmlForm form = new HtmlForm ();
form.Enctype = null;
Assert.AreEqual (String.Empty, form.Enctype, "Enctype");
form.Method = null;
Assert.AreEqual ("post", form.Method, "Method");
form.Name = null;
Assert.AreEqual (form.UniqueID, form.Name, "Name");
form.Target = null;
Assert.AreEqual (String.Empty, form.Target, "Target");
#if NET_2_0
form.DefaultButton = null;
Assert.AreEqual (String.Empty, form.DefaultButton, "DefaultButton");
form.DefaultFocus = null;
Assert.AreEqual (String.Empty, form.DefaultFocus, "DefaultFocus");
#endif
Assert.AreEqual (0, form.Attributes.Count, "Attributes.Count");
}
[Test]
public void Attributes ()
{
HtmlForm form = new HtmlForm ();
IAttributeAccessor a = (IAttributeAccessor)form;
#if NET_2_0
/* not stored in Attributes */
form.DefaultButton = "defaultbutton";
Assert.IsNull (a.GetAttribute ("defaultbutton"), "A1");
/* not stored in Attributes */
form.DefaultFocus = "defaultfocus";
Assert.IsNull (a.GetAttribute ("defaultfocus"), "A2");
#endif
form.Enctype = "enctype";
Assert.AreEqual ("enctype", a.GetAttribute ("enctype"), "A3");
form.Method = "method";
Assert.AreEqual ("method", a.GetAttribute ("method"), "A4");
/* not stored in Attributes */
form.Name = "name";
Assert.AreEqual (form.UniqueID, form.Name, "A5");
Assert.IsNull (form.Name, "A6");
Assert.IsNull (form.UniqueID, "A7");
Assert.IsNull (a.GetAttribute ("name"), "A8");
form.ID = "hithere";
Assert.AreEqual ("hithere", form.Name, "A9");
#if NET_2_0
form.SubmitDisabledControls = true;
Assert.IsNull (a.GetAttribute ("submitdisabledcontrols"), "A10");
#endif
form.Target = "target";
Assert.AreEqual ("target", a.GetAttribute ("target"), "A11");
}
#if NET_2_0
#if !TARGET_DOTNET && !TARGET_JVM
[Test]
public void ActionStringWithQuery ()
{
TestPage p = new TestPage ();
p.SetContext ();
FormPoker form = new FormPoker ();
form.Page = p;
string attrs = form.RenderAttributes ();
// Indirect test for HttpRequest.QueryStringRaw, see
// https://bugzilla.novell.com/show_bug.cgi?id=376352
#if NET_4_0
Assert.AreEqual (" method=\"post\" action=\"?q=1&amp;q2=2\"", attrs, "A1");
form.RenderingCompatibility = new Version (3, 5);
attrs = form.RenderAttributes ();
#endif
Assert.AreEqual (" name=\"aspnetForm\" method=\"post\" action=\"?q=1&amp;q2=2\"", attrs, "A2");
}
#endif
[Test]
public void Undocumented_ActionProperty ()
{
TestPage p = new TestPage ();
p.SetContext ();
FormPoker form = new FormPoker ();
form.Page = p;
form.Action = "someactionfile.aspx";
string attrs = form.RenderAttributes ();
#if NET_4_0
Assert.AreEqual (" method=\"post\" action=\"someactionfile.aspx\"", attrs, "A1");
form.RenderingCompatibility = new Version (3, 5);
attrs = form.RenderAttributes ();
#endif
Assert.AreEqual (" name=\"aspnetForm\" method=\"post\" action=\"someactionfile.aspx\"", attrs, "A2");
}
#endif
[Test]
public void ViewState ()
{
FormPoker form = new FormPoker();
FormPoker copy = new FormPoker();
#if NET_2_0
form.DefaultButton = "defaultbutton";
form.DefaultFocus = "defaultfocus";
#endif
object state = form.SaveState();
copy.LoadState (state);
#if NET_2_0
Assert.AreEqual ("", copy.DefaultButton, "A1");
Assert.AreEqual ("defaultfocus", form.DefaultFocus, "A2");
#endif
}
[Test]
public void Name_InsideNaming ()
{
Control ctrl = new FUControl ();
ctrl.ID = "parent";
FormPoker form = new FormPoker ();
ctrl.Controls.Add (form);
Assert.IsNull (form.ID, "ID");
form.Name = "name";
Assert.AreEqual (form.Name, form.UniqueID, "name and unique id");
form.ID = "id";
Assert.AreEqual ("id", form.ID, "ID-2");
Assert.AreEqual (form.UniqueID, form.Name, "Name-ID");
form.Name = "name";
Assert.AreEqual (form.Name, form.UniqueID, "UniqueID-2");
form.ID = null;
Assert.IsNull (form.ID, "ID-3");
Assert.IsNotNull (form.UniqueID, "UniqueID-3");
Assert.IsNotNull (form.Name, "Name-2");
}
[Test]
[Category ("NotWorking")]
public void RenderChildren ()
{
Page p = new Page();
FormPoker form = new FormPoker ();
form.Page = p;
#if NET_2_0
HtmlDiff.AssertAreEqual ("<div>\r\n<input type=\"hidden\" name=\"__VIEWSTATE\" id=\"\r\n__VIEWSTATE\" value=\"\" />\r\n</div>", form.RenderChildren ().Trim (), "A1");
#else
HtmlDiff.AssertAreEqual ("<input type=\"hidden\" name=\"__VIEWSTATE\" value=\"\" />", form.RenderChildren ().Trim (), "A1");
#endif
}
#if NET_2_0
[Test]
public void ControlCollection ()
{
FormPoker poker = new FormPoker();
ControlCollection col = poker.GetControlCollection();
Assert.AreEqual (col.GetType(), typeof (ControlCollection), "A1");
Assert.IsFalse (col.IsReadOnly, "A2");
Assert.AreEqual (0, col.Count, "A3");
}
#endif
}
}

View File

@@ -0,0 +1,45 @@
//
// HtmlGenericControlCas.cs
// - CAS unit tests for System.Web.UI.HtmlControls.HtmlGenericControl
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// 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.Web.UI.HtmlControls;
namespace MonoCasTests.System.Web.UI.HtmlControls {
[TestFixture]
[Category ("CAS")]
public class HtmlGenericControlCas : AspNetHostingMinimal {
public override Type Type {
get { return typeof (HtmlGenericControl); }
}
}
}

View File

@@ -0,0 +1,49 @@
//
// HtmlHeadBuilderCas.cs
// - CAS unit tests for System.Web.UI.HtmlControls.HtmlHeadBuilder
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Web.UI.HtmlControls;
namespace MonoCasTests.System.Web.UI.HtmlControls {
[TestFixture]
[Category ("CAS")]
public class HtmlHeadBuilderCas : AspNetHostingMinimal {
public override Type Type {
get { return typeof (HtmlHeadBuilder); }
}
}
}
#endif

View File

@@ -0,0 +1,48 @@
//
// HtmlHeadCas.cs - CAS unit tests for System.Web.UI.HtmlControls.HtmlHead
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Web.UI.HtmlControls;
namespace MonoCasTests.System.Web.UI.HtmlControls {
[TestFixture]
[Category ("CAS")]
public class HtmlHeadCas : AspNetHostingMinimal {
public override Type Type {
get { return typeof (HtmlHead); }
}
}
}
#endif

View File

@@ -0,0 +1,56 @@
//
// Author:
// Marek Habersack <grendel@twistedcode.net>
//
// Copyright (C) 2011 Novell, Inc (http://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.Web;
using System.Web.Compilation;
using System.Threading;
using NUnit.Framework;
using MonoTests.SystemWeb.Framework;
using MonoTests.stand_alone.WebHarness;
namespace MonoTests.System.Web.UI.HtmlControls
{
[TestFixture]
public class HtmlHeadTest
{
[TestFixtureSetUp]
public void SetUp ()
{
WebTest.CopyResource (this.GetType (), "HtmlTitleCodeRender_Bug662918.aspx", "HtmlTitleCodeRender_Bug662918.aspx");
}
[Test (Description="Bug #662918")]
public void HtmlTitleCodeRender_Bug662918 ()
{
string origHtml = "<head><title>\r\n\tTitle text\r\n</title></head>";
string pageHtml = new WebTest ("HtmlTitleCodeRender_Bug662918.aspx").Run ();
string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
HtmlDiff.AssertAreEqual (origHtml, renderedHtml, "#A1");
}
}
}

View File

@@ -0,0 +1,58 @@
//
// HtmlImageCas.cs - CAS unit tests for System.Web.UI.HtmlControls.HtmlImage
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// 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.Security.Permissions;
using System.Web.UI.HtmlControls;
using MonoTests.System.Web.UI.HtmlControls;
namespace MonoCasTests.System.Web.UI.HtmlControls {
[TestFixture]
[Category ("CAS")]
public class HtmlImageCas : AspNetHostingMinimal {
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Deny_Unrestricted ()
{
HtmlImageTest unit = new HtmlImageTest ();
unit.DefaultProperties ();
unit.NullProperties ();
unit.Negative ();
unit.RenderAttributes ();
}
public override Type Type {
get { return typeof (HtmlImage); }
}
}
}

View File

@@ -0,0 +1,149 @@
//
// HtmlImageTest.cs
// - Unit tests for System.Web.UI.HtmlControls.HtmlImage
//
// Author:
// Dick Porter <dick@ximian.com>
//
// 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 System.Web.UI.HtmlControls;
using NUnit.Framework;
using MonoTests.SystemWeb.Framework;
using MonoTests.stand_alone.WebHarness;
namespace MonoTests.System.Web.UI.HtmlControls {
public class TestHtmlImage : HtmlImage {
public HtmlTextWriter GetWriter ()
{
StringWriter text = new StringWriter ();
HtmlTextWriter writer = new HtmlTextWriter (text);
base.RenderAttributes (writer);
return writer;
}
}
[TestFixture]
public class HtmlImageTest {
[Test]
public void DefaultProperties ()
{
HtmlImage img = new HtmlImage ();
Assert.AreEqual (0, img.Attributes.Count, "Attributes.Count");
Assert.AreEqual (String.Empty, img.Align, "Align");
Assert.AreEqual (String.Empty, img.Alt, "Alt");
Assert.AreEqual (-1, img.Border, "Border");
Assert.AreEqual (-1, img.Height, "Height");
Assert.AreEqual (String.Empty, img.Src, "Src");
Assert.AreEqual (-1, img.Width, "Width");
Assert.AreEqual ("img", img.TagName, "TagName");
}
[Test]
public void NullProperties ()
{
HtmlImage img = new HtmlImage ();
img.Align = null;
Assert.AreEqual (String.Empty, img.Align, "Align");
img.Alt = null;
Assert.AreEqual (String.Empty, img.Alt, "Alt");
img.Border = -1;
Assert.AreEqual (-1, img.Border, "Border");
img.Height = -1;
Assert.AreEqual (-1, img.Height, "Height");
img.Src = null;
Assert.AreEqual (String.Empty, img.Src, "Src");
img.Width = -1;
Assert.AreEqual (-1, img.Width, "Width");
Assert.AreEqual (0, img.Attributes.Count, "Attributes.Count");
}
[Test]
public void Negative ()
{
HtmlImage img = new HtmlImage ();
img.Border = 10;
img.Height = 20;
img.Width = 30;
Assert.AreEqual (3, img.Attributes.Count, "First Attributes Count");
img.Border = -10;
img.Height = -20;
img.Width = -30;
Assert.AreEqual (-10, img.Border, "Border");
Assert.AreEqual (-20, img.Height, "Height");
Assert.AreEqual (-30, img.Width, "Width");
Assert.AreEqual (3, img.Attributes.Count, "Second Attributes Count");
}
[Test]
public void EmptySrc ()
{
TestHtmlImage img = new TestHtmlImage ();
img.Src = String.Empty;
HtmlTextWriter writer = img.GetWriter ();
Assert.AreEqual (" /", writer.InnerWriter.ToString ());
}
[Test]
[Category ("NunitWeb")]
public void RenderAttributes ()
{
new WebTest (PageInvoker.CreateOnLoad (new PageDelegate (DoRenderAttributes))).Run ();
}
public static void DoRenderAttributes (Page p)
{
TestHtmlImage img = new TestHtmlImage ();
img.Align = "*1*";
img.Alt = "*2*";
img.Border = 3;
img.Height = 4;
img.Src = "*5<&*";
img.Width = 6;
Assert.AreEqual (6, img.Attributes.Count, "Attributes.Count");
HtmlTextWriter writer = img.GetWriter ();
Assert.AreEqual (" src=\"*5<&*\" align=\"*1*\" alt=\"*2*\" border=\"3\" height=\"4\" width=\"6\" /", writer.InnerWriter.ToString ());
}
}
}

View File

@@ -0,0 +1,59 @@
//
// HtmlInputButtonCas.cs
// - CAS unit tests for System.Web.UI.HtmlControls.HtmlInputButton
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// 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.Security.Permissions;
using System.Web.UI.HtmlControls;
using MonoTests.System.Web.UI.HtmlControls;
namespace MonoCasTests.System.Web.UI.HtmlControls {
[TestFixture]
[Category ("CAS")]
public class HtmlInputButtonCas : AspNetHostingMinimal {
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Deny_Unrestricted ()
{
HtmlInputButtonTest unit = new HtmlInputButtonTest ();
unit.Defaults ();
unit.CleanProperties ();
unit.ViewState ();
unit.RenderAttributes ();
}
public override Type Type {
get { return typeof (HtmlInputButton); }
}
}
}

View File

@@ -0,0 +1,275 @@
//
// HtmlInputButtonTest.cs
// - Unit tests for System.Web.UI.HtmlControls.HtmlInputButton
//
// Author:
// Jackson Harper (jackson@ximian.com)
//
// 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 System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using MonoTests.stand_alone.WebHarness;
using NUnit.Framework;
namespace MonoTests.System.Web.UI.HtmlControls {
public class HtmlInputButtonPoker : HtmlInputButton {
public HtmlInputButtonPoker ()
{
TrackViewState ();
}
public HtmlInputButtonPoker (string type) : base (type)
{
TrackViewState ();
}
public object SaveState ()
{
return SaveViewState ();
}
public void LoadState (object state)
{
LoadViewState (state);
}
public void DoRenderAttributes (HtmlTextWriter writer)
{
RenderAttributes (writer);
}
public string RenderToString ()
{
StringWriter sr = new StringWriter ();
RenderAttributes (new HtmlTextWriter (sr));
return sr.ToString ();
}
}
[TestFixture]
public class HtmlInputButtonTest {
[Test]
public void Defaults ()
{
HtmlInputButtonPoker p = new HtmlInputButtonPoker ();
Assert.IsTrue (p.CausesValidation, "A1");
}
[Test]
public void CleanProperties ()
{
HtmlInputButtonPoker p = new HtmlInputButtonPoker ();
p.CausesValidation = false;
Assert.IsFalse (p.CausesValidation, "A1");
p.CausesValidation = true;
Assert.IsTrue (p.CausesValidation, "A2");
p.CausesValidation = false;
Assert.IsFalse (p.CausesValidation, "A3");
}
[Test]
public void ViewState ()
{
HtmlInputButtonPoker p = new HtmlInputButtonPoker ();
#if NET_2_0
p.CausesValidation = false;
p.ValidationGroup = "VG";
#endif
object s = p.SaveState();
HtmlInputButtonPoker copy = new HtmlInputButtonPoker ();
copy.LoadState (s);
#if NET_2_0
Assert.IsFalse (copy.CausesValidation, "A1");
Assert.AreEqual ("VG", p.ValidationGroup, "A2");
#endif
}
[Test]
public void RenderAttributes ()
{
StringWriter sw = new StringWriter ();
HtmlTextWriter tw = new HtmlTextWriter (sw);
HtmlInputButtonPoker p = new HtmlInputButtonPoker ();
p.Page = new Page ();
p.CausesValidation = false;
#if NET_2_0
p.ValidationGroup = "VG";
Assert.AreEqual (3, p.Attributes.Count, "A1");
#else
Assert.AreEqual (2, p.Attributes.Count, "A1");
#endif
tw.WriteBeginTag ("dummy");
p.DoRenderAttributes (tw);
tw.Write ('>');
#if NET_2_0
HtmlDiff.AssertAreEqual ("<dummy name type=\"button\" ValidationGroup=\"VG\" />", sw.ToString (), "A2");
#else
HtmlDiff.AssertAreEqual ("<dummy name type=\"button\" />", sw.ToString (), "A2");
#endif
}
[Test]
public void OnClickAttribute ()
{
StringWriter sw = new StringWriter ();
HtmlTextWriter tw = new HtmlTextWriter (sw);
HtmlInputButtonPoker p = new HtmlInputButtonPoker ();
p.Page = new Page ();
p.DoRenderAttributes (tw);
string str = sw.ToString ();
int found = str.IndexOf ("onclick");
Assert.AreEqual (-1, found, "#01");
p.ServerClick += new EventHandler (EmptyHandler);
sw = new StringWriter ();
tw = new HtmlTextWriter (sw);
p.DoRenderAttributes (tw);
str = sw.ToString ();
found = str.IndexOf ("onclick");
Assert.IsTrue (found >= 0, "#02");
}
[Test]
public void OnClickAttributeWithSpecials ()
{
#if NET_4_0
string origHtml = "alert(&#39;&lt;&amp;&#39;);";
string origHtml2 = "alert('<&');";
#else
string origHtml = "alert('&lt;&amp;');";
string origHtml2 = "alert('<&');";
#endif
StringWriter sw = new StringWriter ();
HtmlTextWriter tw = new HtmlTextWriter (sw);
HtmlInputButtonPoker p = new HtmlInputButtonPoker ();
p.Page = new Page ();
p.Attributes["onclick"] = "alert('<&');";
p.DoRenderAttributes (tw);
string str = sw.ToString ();
int found = str.IndexOf (origHtml);
Assert.IsTrue (found >= 0, "#01");
p.ServerClick += new EventHandler (EmptyHandler);
sw = new StringWriter ();
tw = new HtmlTextWriter (sw);
p.DoRenderAttributes (tw);
str = sw.ToString ();
found = str.IndexOf (origHtml2);
Assert.IsTrue (found >= 0, "#02" + str);
}
private static void EmptyHandler (object sender, EventArgs e)
{
}
[Test]
public void RenderOnclick1 ()
{
HtmlInputButtonPoker it = new HtmlInputButtonPoker ("button");
it.ID = "id1";
it.ServerClick += new EventHandler (EmptyHandler);
string rendered = it.RenderToString ();
Assert.IsTrue (rendered.IndexOf ("onclick") == -1, "#01");
}
[Test]
public void RenderOnclick2 ()
{
Page page = new Page ();
#if NET_2_0
page.EnableEventValidation = false;
#endif
HtmlInputButtonPoker it = new HtmlInputButtonPoker ("button");
page.Controls.Add (it);
it.ID = "id1";
it.ServerClick += new EventHandler (EmptyHandler);
string rendered = it.RenderToString ();
Assert.IsTrue (rendered.IndexOf ("onclick") != -1, "#01");
}
[Test]
public void RenderOnclick3 ()
{
HtmlInputButtonPoker it = new HtmlInputButtonPoker ("submit");
it.ID = "id1";
it.ServerClick += new EventHandler (EmptyHandler);
string rendered = it.RenderToString ();
Assert.IsTrue (rendered.IndexOf ("onclick") == -1, "#01");
}
[Test]
[Category ("NotWorking")]
public void RenderOnclick4 ()
{
Page page = new Page ();
#if NET_2_0
page.EnableEventValidation = false;
#endif
HtmlInputButtonPoker it = new HtmlInputButtonPoker ("submit");
page.Controls.Add (it);
it.ID = "id1";
it.ServerClick += new EventHandler (EmptyHandler);
string rendered = it.RenderToString ();
Assert.IsTrue (rendered.IndexOf ("onclick") != -1, "#01");
Assert.IsTrue (rendered.IndexOf ("__doPostBack") != -1, "#02");
Assert.IsTrue (rendered.IndexOf ("type=\"submit\"") != -1, "#03");
}
[Test]
public void RenderOnclick5 ()
{
Page page = new Page ();
#if NET_2_0
page.EnableEventValidation = false;
#endif
RequiredFieldValidator val = new RequiredFieldValidator ();
val.ControlToValidate = "id1";
page.Validators.Add (val);
HtmlInputButtonPoker it = new HtmlInputButtonPoker ("submit");
page.Controls.Add (it);
it.ID = "id1";
it.ServerClick += new EventHandler (EmptyHandler);
string rendered = it.RenderToString ();
Assert.IsTrue (rendered.IndexOf ("onclick") != -1, "#01");
}
}
}

View File

@@ -0,0 +1,59 @@
//
// HtmlInputCheckBoxCas.cs
// - CAS unit tests for System.Web.UI.HtmlControls.HtmlInputCheckBox
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// 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.Security.Permissions;
using System.Web.UI.HtmlControls;
using MonoTests.System.Web.UI.HtmlControls;
namespace MonoCasTests.System.Web.UI.HtmlControls {
[TestFixture]
[Category ("CAS")]
public class HtmlInputCheckBoxCas : AspNetHostingMinimal {
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Deny_Unrestricted ()
{
HtmlInputCheckBoxTest unit = new HtmlInputCheckBoxTest ();
unit.DefaultProperties ();
unit.NullProperties ();
unit.CleanProperties ();
unit.Render ();
}
public override Type Type {
get { return typeof (HtmlInputCheckBox); }
}
}
}

View File

@@ -0,0 +1,110 @@
//
// HtmlInputCheckBoxTest.cs
// - Unit tests for System.Web.UI.HtmlControls.HtmlInputCheckBox
//
// Author:
// Dick Porter <dick@ximian.com>
//
// 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 System.Web.UI.HtmlControls;
using MonoTests.stand_alone.WebHarness;
using NUnit.Framework;
namespace MonoTests.System.Web.UI.HtmlControls {
public class TestHtmlInputCheckBox : HtmlInputCheckBox {
public string Render ()
{
HtmlTextWriter writer = new HtmlTextWriter (new StringWriter ());
base.Render (writer);
return writer.InnerWriter.ToString ();
}
}
[TestFixture]
public class HtmlInputCheckBoxTest {
[Test]
public void DefaultProperties ()
{
HtmlInputCheckBox c = new HtmlInputCheckBox ();
Assert.AreEqual (1, c.Attributes.Count, "Attributes.Count");
Assert.IsFalse (c.Checked, "Checked");
Assert.AreEqual (1, c.Attributes.Count, "Attributes.Count after");
}
[Test]
public void NullProperties ()
{
HtmlInputCheckBox c = new HtmlInputCheckBox ();
Assert.AreEqual (1, c.Attributes.Count, "Attributes.Count");
Assert.AreEqual ("checkbox", c.Attributes["type"], "Attributes[\"type\"]");
c.Checked = true;
Assert.IsTrue (c.Checked, "Checked");
Assert.AreEqual (2, c.Attributes.Count, "Attributes.Count after");
Assert.AreEqual ("checked", c.Attributes["checked"], "Attributes[\"checked\"]");
}
[Test]
public void CleanProperties ()
{
HtmlInputCheckBox c = new HtmlInputCheckBox ();
c.Checked = true;
Assert.AreEqual (2, c.Attributes.Count, "Attributes.Count");
c.Checked = false;
Assert.AreEqual (1, c.Attributes.Count, "Attributes.Count after");
}
[Test]
public void Render ()
{
TestHtmlInputCheckBox c = new TestHtmlInputCheckBox ();
c.ID = "*1*";
string s = c.Render ();
Assert.IsTrue (s.IndexOf (" type=\"checkbox\"") > 0, "type");
c.Checked = true;
s = c.Render ();
#if NET_2_0
HtmlDiff.AssertAreEqual ("<input name=\"*1*\" id=\"*1*\" type=\"checkbox\" checked=\"checked\" />", s, "Render fail");
#else
HtmlDiff.AssertAreEqual ("<input name=\"*1*\" type=\"checkbox\" id=\"*1*\" checked=\"checked\" />", s, "Render fail");
#endif
}
}
}

Some files were not shown because too many files have changed in this diff Show More