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,8 @@
thisdir = class/System.Web.Extensions/Test
include ../../../build/rules.make
all-local install-local clean-local test-local run-test-local run-test-ondotnet-local uninstall-local doc-update-local csproj-local:
DISTFILES = $(wildcard *.aspx)
dist-local: dist-default

View File

@@ -0,0 +1,38 @@
2009-08-17 Marek Habersack <mhabersack@novell.com>
* JavaScriptSerializerTest.cs: fixed broken tests
2009-06-18 Marek Habersack <mhabersack@novell.com>
* JavaScriptSerializerTest.cs: added comparison with the
.NET-generated serialization result in TestDeserialize and
TestDeserializeTypeResolver tests.
2009-03-17 Marek Habersack <mhabersack@novell.com>
* JavaScriptSerializerTest.cs: added tests for conversion to
IDictionary and IDictionary <K,V> types.
2009-03-06 Marek Habersack <mhabersack@novell.com>
* JavaScriptSerializerTest.cs: added a test for unquoted tests
surrounded with spaces.
2008-10-22 Marek Habersack <mhabersack@novell.com>
* JavaScriptSerializerTest.cs: added tests for deserialization of
objects with more than one unquoted key names.
2008-09-20 Juraj Skripsky <js@hotfeet.ch>
* JavaScriptSerializerTest.cs: added test for bug #424704.
2008-09-20 Marek Habersack <mhabersack@novell.com>
* JavaScriptSerializerTest.cs: added some tests
2008-09-19 Marek Habersack <mhabersack@novell.com>
* JavaScriptSerializerTest.cs: enabled some tests which were
failing with the old (de)serializer, but work with the new one.

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
2009-10-08 Atsushi Enomoto <atsushi@ximian.com>
* ProxyGeneratorTest.cs : new test, for WCF AJAX interop.

View File

@@ -0,0 +1,79 @@
//
// ProxyGeneratorTest.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2009 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.Net;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Web.Script.Services;
using System.Text;
using NUnit.Framework;
namespace MonoTests.System.Web.Script.Services
{
[TestFixture]
public class ProxyGeneratorTest
{
[Test]
public void ScriptGenerator ()
{
var s = ProxyGenerator.GetClientProxyScript (typeof (IHogeService), "/js", false);
Assert.IsTrue (s.IndexOf ("IHogeService") > 0, "#1");
Assert.IsTrue (s.IndexOf ("Join") > 0, "#2");
s = ProxyGenerator.GetClientProxyScript (typeof (IHogeService), "/jsdebug", true);
Assert.IsTrue (s.IndexOf ("IHogeService") > 0, "#3");
Assert.IsTrue (s.IndexOf ("Join") > 0, "#4");
}
[ServiceContract]
public interface IHogeService
{
// [WebGet]
[OperationContract]
string Echo (string s);
// [WebGet]
[OperationContract]
string Join (string s1, string s2);
}
public class HogeService : IHogeService
{
public string Echo (string s)
{
return "heh, I don't";
}
public string Join (string s1, string s2)
{
Console.WriteLine ("{0} + {1}", s1, s2);
return s1 + s2;
}
}
}
}

View File

@@ -0,0 +1,30 @@
2009-06-18 Marek Habersack <mhabersack@novell.com>
* ListViewTest.cs: hushed the output in ListView_Edit ()
2008-11-20 Marek Habersack <mhabersack@novell.com>
* ListViewTest.cs: added tests for several properties.
2008-11-19 Marek Habersack <mhabersack@novell.com>
* EventRecorder.cs: class is now serializable.
* ListViewTest.cs: use system.web Mainsoft test framework.
ListViewPoker is now able to record events.
Added wrappers for ListView protected methods to ListViewPoker,
Added two simple test ITemplate classes.
Added tests for initial values.
Added tests for all the methods which can be tested in a simple
way, without using a real asp.net page.
Added test for the Edit functionality.
2008-10-30 Marek Habersack <mhabersack@novell.com>
* DataPagerFieldCollectionTest.cs: created. Some basic tests for
DataPagerFieldCollection
* EventRecorder.cs: created. A helper class for tests.
* ListViewTest.cs: created. Some basic test for ListView.

View File

@@ -0,0 +1,225 @@
//
// System.Web.UI.WebControls.ListView
//
// Authors:
// Marek Habersack (mhabersack@novell.com)
//
// (C) 2008 Novell, Inc
//
//
// 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_3_5
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Web.UI;
using System.Web.UI.WebControls;
using NUnit.Framework;
namespace MonoTests.System.Web.UI.WebControls
{
class DataPagerFieldCollectionPoker : DataPagerFieldCollection
{
EventRecorder recorder;
void RecordEvent (string suffix)
{
if (recorder == null)
return;
recorder.Record (suffix);
}
public DataPagerFieldCollectionPoker ()
: base (null)
{
}
public DataPagerFieldCollectionPoker (DataPager pager)
: base (pager)
{
}
public DataPagerFieldCollectionPoker (DataPager pager, EventRecorder recorder)
: base (pager)
{
this.recorder = recorder;
}
public Type[] DoGetKnownTypes ()
{
return base.GetKnownTypes ();
}
public object DoCreateKnownType (int index)
{
return CreateKnownType (index);
}
public void DoOnValidate (object value)
{
OnValidate (value);
}
public void CatchFieldsChangedEvent ()
{
FieldsChanged += new EventHandler (OnFieldsChanged);
}
protected override void OnValidate (object o)
{
RecordEvent ("Enter");
base.OnValidate (o);
RecordEvent ("Leave");
}
protected override void OnClearComplete ()
{
RecordEvent ("Enter");
base.OnClearComplete ();
RecordEvent ("Leave");
}
protected override void OnInsertComplete (int index, object value)
{
RecordEvent ("Enter");
base.OnInsertComplete (index, value);
RecordEvent ("Leave");
}
protected override void OnRemoveComplete (int index, object value)
{
RecordEvent ("Enter");
base.OnRemoveComplete (index, value);
RecordEvent ("Leave");
}
void OnFieldsChanged (object sender, EventArgs args)
{
RecordEvent ("Enter");
RecordEvent ("Leave");
}
}
[TestFixture]
public class DataPagerCollectionTest
{
[Test]
public void GetKnownTypes_Test ()
{
var coll = new DataPagerFieldCollectionPoker ();
Type[] knownTypes = coll.DoGetKnownTypes ();
Assert.AreEqual (3, knownTypes.Length, "#A1");
Assert.AreEqual (typeof (NextPreviousPagerField), knownTypes [0], "#A2");
Assert.AreEqual (typeof (NumericPagerField), knownTypes [1], "#A3");
Assert.AreEqual (typeof (TemplatePagerField), knownTypes [2], "#A4");
}
[Test]
public void CreateKnownTypes_Types ()
{
var coll = new DataPagerFieldCollectionPoker ();
Assert.AreEqual (typeof (NextPreviousPagerField), coll.DoCreateKnownType (0).GetType (), "#A1");
Assert.AreEqual (typeof (NumericPagerField), coll.DoCreateKnownType (1).GetType (), "#A2");
Assert.AreEqual (typeof (TemplatePagerField), coll.DoCreateKnownType (2).GetType (), "#A3");
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void CreateKnownTypes_Arguments ()
{
var coll = new DataPagerFieldCollectionPoker ();
coll.DoCreateKnownType (3);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void OnValidate_Arguments_Null ()
{
var coll = new DataPagerFieldCollectionPoker ();
coll.DoOnValidate (null);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void OnValidate_Arguments_NotDataPagerField ()
{
var coll = new DataPagerFieldCollectionPoker ();
coll.DoOnValidate (String.Empty);
}
[Test]
public void DataPagerFieldCollection_Events ()
{
var events = new EventRecorder ();
var coll = new DataPagerFieldCollectionPoker (new DataPager (), events);
coll.CatchFieldsChangedEvent ();
coll.Insert (0, new NextPreviousPagerField ());
Assert.AreEqual (6, events.Count);
Assert.AreEqual ("OnValidate:Enter", events [0], "#A1");
Assert.AreEqual ("OnValidate:Leave", events [1], "#A2");
Assert.AreEqual ("OnInsertComplete:Enter", events [2], "#A3");
Assert.AreEqual ("OnFieldsChanged:Enter", events [3], "#A4");
Assert.AreEqual ("OnFieldsChanged:Leave", events [4], "#A5");
Assert.AreEqual ("OnInsertComplete:Leave", events [5], "#A6");
events.Clear ();
coll.Clear ();
Assert.AreEqual (4, events.Count);
Assert.AreEqual ("OnClearComplete:Enter", events [0], "#B1");
Assert.AreEqual ("OnFieldsChanged:Enter", events [1], "#B2");
Assert.AreEqual ("OnFieldsChanged:Leave", events [2], "#B3");
Assert.AreEqual ("OnClearComplete:Leave", events [3], "#B4");
NextPreviousPagerField field = new NextPreviousPagerField ();
coll.Insert (0, field);
events.Clear ();
coll.Remove (field);
Assert.AreEqual (8, events.Count);
Assert.AreEqual ("OnValidate:Enter", events [0], "#C1");
Assert.AreEqual ("OnValidate:Leave", events [1], "#C2");
Assert.AreEqual ("OnValidate:Enter", events [2], "#C3");
Assert.AreEqual ("OnValidate:Leave", events [3], "#C4");
Assert.AreEqual ("OnRemoveComplete:Enter", events [4], "#C5");
Assert.AreEqual ("OnFieldsChanged:Enter", events [5], "#C6");
Assert.AreEqual ("OnFieldsChanged:Leave", events [6], "#C7");
Assert.AreEqual ("OnRemoveComplete:Leave", events [7], "#C8");
coll.Insert (0, field);
events.Clear ();
coll.RemoveAt (0);
Assert.AreEqual (4, events.Count);
Assert.AreEqual ("OnRemoveComplete:Enter", events [0], "#D1");
Assert.AreEqual ("OnFieldsChanged:Enter", events [1], "#D2");
Assert.AreEqual ("OnFieldsChanged:Leave", events [2], "#D3");
Assert.AreEqual ("OnRemoveComplete:Leave", events [3], "#D4");
}
}
}
#endif

View File

@@ -0,0 +1,58 @@
//
// System.Web.UI.WebControls.ListView
//
// Authors:
// Marek Habersack (mhabersack@novell.com)
//
// (C) 2008 Novell, Inc
//
//
// 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_3_5
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
namespace MonoTests.System.Web.UI.WebControls
{
[Serializable]
public sealed class EventRecorder : List <string>
{
List <string> list;
public EventRecorder ()
{
list = (List <string>)this;
}
public void Record (string suffix)
{
var sf = new StackFrame (2);
MethodBase mb = sf.GetMethod ();
list.Add (mb.Name + ":" + suffix);
sf = null;
mb = null;
}
}
}
#endif

View File

@@ -0,0 +1,232 @@
//
// System.Web.UI.WebControls.ListView
//
// Authors:
// Marek Habersack (mhabersack@novell.com)
//
// (C) 2009 Novell, Inc
//
//
// 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_3_5
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using NUnit.Framework;
using MonoTests.SystemWeb.Framework;
using MonoTests.stand_alone.WebHarness;
namespace MonoTests.System.Web.UI.WebControls
{
[TestFixture]
public class ListViewPagedDataSourceTest
{
string EnumerableToString (IEnumerable data)
{
var sb = new StringBuilder ();
foreach (object d in data)
sb.Append (d.ToString ());
return sb.ToString ();
}
List<string> GetData (int count)
{
var ret = new List<string> ();
for (int i = 0; i < count; i++)
ret.Add (i.ToString ());
return ret;
}
ListViewPagedDataSource GetDataSource (List<string> ds, int startRowIndex, int maximumRows, int totalRowCount, bool allowServerPaging)
{
var ret = new ListViewPagedDataSource ();
ret.DataSource = ds;
ret.StartRowIndex = startRowIndex;
ret.MaximumRows = maximumRows;
ret.TotalRowCount = totalRowCount;
ret.AllowServerPaging = allowServerPaging;
return ret;
}
[Test]
public void Counts ()
{
List<string> l = GetData (10);
ListViewPagedDataSource pds = GetDataSource (l, 0, 10, 25, false);
Assert.AreEqual (10, pds.Count, "#A1-1");
Assert.AreEqual (10, pds.DataSourceCount, "#A1-2");
pds = GetDataSource (l, 0, 10, 25, true);
Assert.AreEqual (10, pds.Count, "#A2-1");
Assert.AreEqual (25, pds.DataSourceCount, "#A2-2");
pds = GetDataSource (l, 10, 10, 25, false);
Assert.AreEqual (0, pds.Count, "#A3-1");
Assert.AreEqual (10, pds.DataSourceCount, "#A3-2");
pds = GetDataSource (l, 10, 10, 25, true);
Assert.AreEqual (10, pds.Count, "#A4-1");
Assert.AreEqual (25, pds.DataSourceCount, "#A4-2");
pds = GetDataSource (l, 15, 10, 25, false);
Assert.AreEqual (-5, pds.Count, "#A5-1");
Assert.AreEqual (10, pds.DataSourceCount, "#A5-2");
pds = GetDataSource (l, 15, 10, 25, true);
Assert.AreEqual (10, pds.Count, "#A6-1");
Assert.AreEqual (25, pds.DataSourceCount, "#A6-2");
pds = GetDataSource (l, 20, 10, 25, false);
Assert.AreEqual (-10, pds.Count, "#A7-1");
Assert.AreEqual (10, pds.DataSourceCount, "#A7-2");
pds = GetDataSource (l, 20, 10, 25, true);
Assert.AreEqual (5, pds.Count, "#A8-1");
Assert.AreEqual (25, pds.DataSourceCount, "#A8-2");
pds = GetDataSource (l, 25, 10, 25, false);
Assert.AreEqual (-15, pds.Count, "#A9-1");
Assert.AreEqual (10, pds.DataSourceCount, "#A9-2");
pds = GetDataSource (l, 25, 10, 25, true);
Assert.AreEqual (0, pds.Count, "#A10-1");
Assert.AreEqual (25, pds.DataSourceCount, "#A10-2");
pds = GetDataSource (l, 30, 10, 25, false);
Assert.AreEqual (-20, pds.Count, "#A11-1");
Assert.AreEqual (10, pds.DataSourceCount, "#A11-2");
pds = GetDataSource (l, 30, 10, 25, true);
Assert.AreEqual (-5, pds.Count, "#A12-1");
Assert.AreEqual (25, pds.DataSourceCount, "#A12-2");
l = GetData (11);
pds = GetDataSource (l, 0, 11, 25, false);
Assert.AreEqual (11, pds.Count, "#B1-1");
Assert.AreEqual (11, pds.DataSourceCount, "#B1-2");
pds = GetDataSource (l, 0, 11, 25, true);
Assert.AreEqual (11, pds.Count, "#B2-1");
Assert.AreEqual (25, pds.DataSourceCount, "#B2-2");
pds = GetDataSource (l, 10, 11, 25, false);
Assert.AreEqual (1, pds.Count, "#B3-1");
Assert.AreEqual (11, pds.DataSourceCount, "#B3-2");
pds = GetDataSource (l, 10, 11, 25, true);
Assert.AreEqual (11, pds.Count, "#B4-1");
Assert.AreEqual (25, pds.DataSourceCount, "#B4-2");
pds = GetDataSource (l, 15, 11, 25, false);
Assert.AreEqual (-4, pds.Count, "#B5-1");
Assert.AreEqual (11, pds.DataSourceCount, "#B5-2");
pds = GetDataSource (l, 15, 11, 25, true);
Assert.AreEqual (10, pds.Count, "#B6-1");
Assert.AreEqual (25, pds.DataSourceCount, "#B6-2");
pds = GetDataSource (l, 20, 11, 25, false);
Assert.AreEqual (-9, pds.Count, "#B7-1");
Assert.AreEqual (11, pds.DataSourceCount, "#B7-2");
pds = GetDataSource (l, 20, 11, 25, true);
Assert.AreEqual (5, pds.Count, "#B8-1");
Assert.AreEqual (25, pds.DataSourceCount, "#B8-2");
pds = GetDataSource (l, 25, 11, 25, false);
Assert.AreEqual (-14, pds.Count, "#B9-1");
Assert.AreEqual (11, pds.DataSourceCount, "#B9-2");
pds = GetDataSource (l, 25, 11, 25, true);
Assert.AreEqual (0, pds.Count, "#B10-1");
Assert.AreEqual (25, pds.DataSourceCount, "#B10-2");
pds = GetDataSource (l, 30, 11, 25, false);
Assert.AreEqual (-19, pds.Count, "#B11-1");
Assert.AreEqual (11, pds.DataSourceCount, "#B11-2");
pds = GetDataSource (l, 30, 11, 25, true);
Assert.AreEqual (-5, pds.Count, "#B12-1");
Assert.AreEqual (25, pds.DataSourceCount, "#B12-2");
}
[Test]
public void Enumerator ()
{
List<string> l = GetData (10);
ListViewPagedDataSource pds = GetDataSource (l, 0, 10, 25, false);
Assert.AreEqual ("0123456789", EnumerableToString (pds), "#A1");
pds = GetDataSource (l, 5, 10, 25, false);
Assert.AreEqual ("56789", EnumerableToString (pds), "#A2");
pds = GetDataSource (l, 9, 10, 25, false);
Assert.AreEqual ("9", EnumerableToString (pds), "#A3");
pds = GetDataSource (l, 10, 10, 25, false);
Assert.AreEqual (String.Empty, EnumerableToString (pds), "#A4");
pds = GetDataSource (l, 20, 10, 25, false);
Assert.AreEqual (String.Empty, EnumerableToString (pds), "#A5");
pds = GetDataSource (l, 25, 10, 25, false);
Assert.AreEqual (String.Empty, EnumerableToString (pds), "#A6");
pds = GetDataSource (l, 30, 10, 25, false);
Assert.AreEqual (String.Empty, EnumerableToString (pds), "#A7");
pds = GetDataSource (l, 0, 10, 25, true);
Assert.AreEqual ("0123456789", EnumerableToString (pds), "#B1");
pds = GetDataSource (l, 5, 10, 25, true);
Assert.AreEqual ("0123456789", EnumerableToString (pds), "#B2");
pds = GetDataSource (l, 9, 10, 25, true);
Assert.AreEqual ("0123456789", EnumerableToString (pds), "#B3");
pds = GetDataSource (l, 10, 10, 25, true);
Assert.AreEqual ("0123456789", EnumerableToString (pds), "#B4");
pds = GetDataSource (l, 20, 10, 25, true);
Assert.AreEqual ("01234", EnumerableToString (pds), "#B5");
pds = GetDataSource (l, 25, 10, 25, true);
Assert.AreEqual (String.Empty, EnumerableToString (pds), "#B6");
pds = GetDataSource (l, 30, 10, 25, true);
Assert.AreEqual (String.Empty, EnumerableToString (pds), "#B7");
}
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,6 @@
2010-02-02 Marek Habersack <mhabersack@novell.com>
* ScriptBehaviorDescriptorTest.cs,
ScriptComponentDescriptorTest.cs: added tests for rendering of the
Name and ID properties.

View File

@@ -0,0 +1,224 @@
//
// ScriptBehaviorDescriptorTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.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.Text;
using NUnit.Framework;
using System.Web.UI;
namespace Tests.System.Web.UI
{
[TestFixture]
public class ScriptBehaviorDescriptorTest
{
class PokerScriptBehaviorDescriptor : ScriptBehaviorDescriptor
{
public PokerScriptBehaviorDescriptor (string type, string elementID) : base (type, elementID) { }
public string DoGetScript () {
return GetScript ();
}
}
[Test]
public void ScriptBehaviorDescriptor_Defaults ()
{
PokerScriptBehaviorDescriptor scd = new PokerScriptBehaviorDescriptor ("My.Type", "Element1");
Assert.AreEqual ("My.Type", scd.Type, "Type");
Assert.AreEqual ("Type", scd.Name, "Name");
Assert.AreEqual (String.Empty, scd.ID, "ID");
Assert.AreEqual ("Element1$Type", scd.ClientID, "ClientID");
Assert.AreEqual ("Element1", scd.ElementID, "ElementID");
string script = scd.DoGetScript ();
Assert.AreEqual ("$create(My.Type, null, null, null, $get(\"Element1\"));", script, "#A1");
scd.ID = "SomeID";
script = scd.DoGetScript ();
Assert.AreEqual ("$create(My.Type, {\"id\":\"SomeID\"}, null, null, $get(\"Element1\"));", script, "#A2");
scd.Name = "SomeName";
script = scd.DoGetScript ();
Assert.AreEqual ("$create(My.Type, {\"id\":\"SomeID\",\"name\":\"SomeName\"}, null, null, $get(\"Element1\"));", script, "#A3");
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ScriptBehaviorDescriptor_ctor_exception_1 () {
ScriptBehaviorDescriptor scd = new ScriptBehaviorDescriptor ("My.Type", null);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ScriptBehaviorDescriptor_ctor_exception_2 () {
ScriptBehaviorDescriptor scd = new ScriptBehaviorDescriptor ("My.Type", String.Empty);
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptBehaviorDescriptor_AddComponentProperty () {
PokerScriptBehaviorDescriptor scd = new PokerScriptBehaviorDescriptor ("My.Type", "Element1");
scd.AddComponentProperty ("myName1", "myCompId1");
scd.AddComponentProperty ("myName2", "myCompId2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, null, null, {\"myName2\":\"myCompId2\",\"myName1\":\"myCompId1\"}, $get(\"Element1\"));", script);
#else
Assert.AreEqual ("$create(My.Type, null, null, {\"myName1\":\"myCompId1\",\"myName2\":\"myCompId2\"}, $get(\"Element1\"));", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptBehaviorDescriptor_AddElementProperty () {
PokerScriptBehaviorDescriptor scd = new PokerScriptBehaviorDescriptor ("My.Type", "Element1");
scd.AddElementProperty ("myName1", "myElemId1");
scd.AddElementProperty ("myName2", "myElemId2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, {\"myName2\":$get(\"myElemId2\"),\"myName1\":$get(\"myElemId1\")}, null, null, $get(\"Element1\"));", script);
#else
Assert.AreEqual ("$create(My.Type, {\"myName1\":$get(\"myElemId1\"),\"myName2\":$get(\"myElemId2\")}, null, null, $get(\"Element1\"));", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptBehaviorDescriptor_AddProperty () {
PokerScriptBehaviorDescriptor scd = new PokerScriptBehaviorDescriptor ("My.Type", "Element1");
scd.AddProperty ("myName1", "myValue1");
scd.AddProperty ("myName2", "myValue2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, {\"myName2\":\"myValue2\",\"myName1\":\"myValue1\"}, null, null, $get(\"Element1\"));", script);
#else
Assert.AreEqual ("$create(My.Type, {\"myName1\":\"myValue1\",\"myName2\":\"myValue2\"}, null, null, $get(\"Element1\"));", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptBehaviorDescriptor_AddProperty_Null () {
PokerScriptBehaviorDescriptor scd = new PokerScriptBehaviorDescriptor ("My.Type", "Element1");
scd.AddProperty ("myName1", null);
scd.AddProperty ("myName2", null);
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, {\"myName2\":null,\"myName1\":null}, null, null, $get(\"Element1\"));", script);
#else
Assert.AreEqual ("$create(My.Type, {\"myName1\":null,\"myName2\":null}, null, null, $get(\"Element1\"));", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptBehaviorDescriptor_AddEvent () {
PokerScriptBehaviorDescriptor scd = new PokerScriptBehaviorDescriptor ("My.Type", "Element1");
scd.AddEvent ("myName1", "myHandler1");
scd.AddEvent ("myName2", "myHandler2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, null, {\"myName2\":myHandler2,\"myName1\":myHandler1}, null, $get(\"Element1\"));", script);
#else
Assert.AreEqual ("$create(My.Type, null, {\"myName1\":myHandler1,\"myName2\":myHandler2}, null, $get(\"Element1\"));", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptBehaviorDescriptor_AddScriptProperty () {
PokerScriptBehaviorDescriptor scd = new PokerScriptBehaviorDescriptor ("My.Type", "Element1");
scd.AddScriptProperty ("myName1", "myScript1");
scd.AddScriptProperty ("myName2", "myScript2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, {\"myName2\":myScript2,\"myName1\":myScript1}, null, null, $get(\"Element1\"));", script);
#else
Assert.AreEqual ("$create(My.Type, {\"myName1\":myScript1,\"myName2\":myScript2}, null, null, $get(\"Element1\"));", script);
#endif
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ScriptBehaviorDescriptor_Type_exception_1 () {
PokerScriptBehaviorDescriptor scd = new PokerScriptBehaviorDescriptor ("My.Type", "Element1");
scd.Type = null;
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ScriptBehaviorDescriptor_Type_exception_2 () {
PokerScriptBehaviorDescriptor scd = new PokerScriptBehaviorDescriptor ("My.Type", "Element1");
scd.Type = String.Empty;
}
[Test]
public void ScriptBehaviorDescriptor_Type () {
PokerScriptBehaviorDescriptor scd = new PokerScriptBehaviorDescriptor ("My.Type", "Element1");
scd.Type = "New.Type";
Assert.AreEqual ("New.Type", scd.Type, "Type");
}
[Test]
public void ScriptBehaviorDescriptor_ID () {
PokerScriptBehaviorDescriptor scd = new PokerScriptBehaviorDescriptor ("My.Type", "Element1");
scd.ID = null;
Assert.AreEqual (String.Empty, scd.ID, "#1");
scd.ID = String.Empty;
Assert.AreEqual (String.Empty, scd.ID, "#2");
scd.ID = "My ID";
Assert.AreEqual ("My ID", scd.ID, "#3");
Assert.AreEqual ("My ID", scd.ClientID, "#4");
}
[Test]
public void ScriptBehaviorDescriptor_Name () {
PokerScriptBehaviorDescriptor scd = new PokerScriptBehaviorDescriptor ("My.Type", "Element1");
scd.Name = null;
Assert.AreEqual ("Type", scd.Name, "#1");
scd.Name = String.Empty;
Assert.AreEqual ("Type", scd.Name, "#2");
scd.Name = "MyName";
Assert.AreEqual ("MyName", scd.Name, "#3");
Assert.AreEqual ("Element1$MyName", scd.ClientID, "#4");
scd.Name = "MyName.MyType";
Assert.AreEqual ("MyName.MyType", scd.Name, "#5");
scd.Name = null;
Assert.AreEqual ("Type", scd.Name, "#6");
}
}
}

View File

@@ -0,0 +1,202 @@
//
// ScriptComponentDescriptorTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.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.Text;
using NUnit.Framework;
using System.Web.UI;
namespace Tests.System.Web.UI
{
[TestFixture]
public class ScriptComponentDescriptorTest
{
class PokerScriptComponentDescriptor : ScriptComponentDescriptor
{
public PokerScriptComponentDescriptor (string type) : base (type) { }
public string DoGetScript () {
return GetScript ();
}
}
[Test]
public void ScriptComponentDescriptor_Defaults ()
{
PokerScriptComponentDescriptor scd = new PokerScriptComponentDescriptor ("My.Type");
Assert.AreEqual ("My.Type", scd.Type, "Type");
Assert.AreEqual (String.Empty, scd.ID, "ID");
Assert.AreEqual (String.Empty, scd.ClientID, "ClientID");
string script = scd.DoGetScript ();
Assert.AreEqual ("$create(My.Type, null, null, null);", script, "#A1");
scd.ID = "SomeID";
script = scd.DoGetScript ();
Assert.AreEqual ("$create(My.Type, {\"id\":\"SomeID\"}, null, null);", script, "#A2");
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ScriptComponentDescriptor_ctor_exception_1 () {
ScriptComponentDescriptor scd = new ScriptComponentDescriptor (null);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ScriptComponentDescriptor_ctor_exception_2 () {
ScriptComponentDescriptor scd = new ScriptComponentDescriptor (String.Empty);
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptComponentDescriptor_AddComponentProperty () {
PokerScriptComponentDescriptor scd = new PokerScriptComponentDescriptor ("My.Type");
scd.AddComponentProperty ("myName1", "myCompId1");
scd.AddComponentProperty ("myName2", "myCompId2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, null, null, {\"myName2\":\"myCompId2\",\"myName1\":\"myCompId1\"});", script);
#else
Assert.AreEqual ("$create(My.Type, null, null, {\"myName1\":\"myCompId1\",\"myName2\":\"myCompId2\"});", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptComponentDescriptor_AddElementProperty () {
PokerScriptComponentDescriptor scd = new PokerScriptComponentDescriptor ("My.Type");
scd.AddElementProperty ("myName1", "myElemId1");
scd.AddElementProperty ("myName2", "myElemId2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, {\"myName2\":$get(\"myElemId2\"),\"myName1\":$get(\"myElemId1\")}, null, null);", script);
#else
Assert.AreEqual ("$create(My.Type, {\"myName1\":$get(\"myElemId1\"),\"myName2\":$get(\"myElemId2\")}, null, null);", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptComponentDescriptor_AddProperty () {
PokerScriptComponentDescriptor scd = new PokerScriptComponentDescriptor ("My.Type");
scd.AddProperty ("myName1", "myValue1");
scd.AddProperty ("myName2", "myValue2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, {\"myName2\":\"myValue2\",\"myName1\":\"myValue1\"}, null, null);", script);
#else
Assert.AreEqual ("$create(My.Type, {\"myName1\":\"myValue1\",\"myName2\":\"myValue2\"}, null, null);", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptComponentDescriptor_AddProperty_Null () {
PokerScriptComponentDescriptor scd = new PokerScriptComponentDescriptor ("My.Type");
scd.AddProperty ("myName1", null);
scd.AddProperty ("myName2", null);
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, {\"myName2\":null,\"myName1\":null}, null, null);", script);
#else
Assert.AreEqual ("$create(My.Type, {\"myName1\":null,\"myName2\":null}, null, null);", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptComponentDescriptor_AddEvent () {
PokerScriptComponentDescriptor scd = new PokerScriptComponentDescriptor ("My.Type");
scd.AddEvent ("myName1", "myHandler1");
scd.AddEvent ("myName2", "myHandler2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, null, {\"myName2\":myHandler2,\"myName1\":myHandler1}, null);", script);
#else
Assert.AreEqual ("$create(My.Type, null, {\"myName1\":myHandler1,\"myName2\":myHandler2}, null);", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptComponentDescriptor_AddScriptProperty () {
PokerScriptComponentDescriptor scd = new PokerScriptComponentDescriptor ("My.Type");
scd.AddScriptProperty ("myName1", "myScript1");
scd.AddScriptProperty ("myName2", "myScript2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, {\"myName2\":myScript2,\"myName1\":myScript1}, null, null);", script);
#else
Assert.AreEqual ("$create(My.Type, {\"myName1\":myScript1,\"myName2\":myScript2}, null, null);", script);
#endif
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ScriptComponentDescriptor_Type_exception_1 () {
PokerScriptComponentDescriptor scd = new PokerScriptComponentDescriptor ("My.Type");
scd.Type = null;
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ScriptComponentDescriptor_Type_exception_2 () {
PokerScriptComponentDescriptor scd = new PokerScriptComponentDescriptor ("My.Type");
scd.Type = String.Empty;
}
[Test]
public void ScriptComponentDescriptor_Type () {
PokerScriptComponentDescriptor scd = new PokerScriptComponentDescriptor ("My.Type");
scd.Type = "New.Type";
Assert.AreEqual ("New.Type", scd.Type, "Type");
}
[Test]
public void ScriptComponentDescriptor_ID () {
PokerScriptComponentDescriptor scd = new PokerScriptComponentDescriptor ("My.Type");
scd.ID = null;
Assert.AreEqual (String.Empty, scd.ID, "#1");
scd.ID = String.Empty;
Assert.AreEqual (String.Empty, scd.ID, "#2");
scd.ID = "My ID";
Assert.AreEqual ("My ID", scd.ID, "#3");
Assert.AreEqual ("My ID", scd.ClientID, "#4");
}
}
}

View File

@@ -0,0 +1,193 @@
//
// ScriptControlDescriptorTest.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.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.Text;
using NUnit.Framework;
using System.Web.UI;
namespace Tests.System.Web.UI
{
[TestFixture]
public class ScriptControlDescriptorTest
{
class PokerScriptControlDescriptor : ScriptControlDescriptor
{
public PokerScriptControlDescriptor (string type, string elementID) : base (type, elementID) { }
public string DoGetScript () {
return GetScript ();
}
}
[Test]
public void ScriptControlDescriptor_Defaults () {
PokerScriptControlDescriptor scd = new PokerScriptControlDescriptor ("My.Type", "Element1");
Assert.AreEqual ("My.Type", scd.Type, "Type");
Assert.AreEqual (String.Empty, scd.ID, "ID");
Assert.AreEqual ("Element1", scd.ClientID, "ClientID");
Assert.AreEqual ("Element1", scd.ElementID, "ElementID");
string script = scd.DoGetScript ();
Assert.AreEqual ("$create(My.Type, null, null, null, $get(\"Element1\"));", script);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ScriptControlDescriptor_ctor_exception_1 () {
ScriptControlDescriptor scd = new ScriptControlDescriptor ("My.Type", null);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ScriptControlDescriptor_ctor_exception_2 () {
ScriptControlDescriptor scd = new ScriptControlDescriptor ("My.Type", String.Empty);
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptControlDescriptor_AddComponentProperty () {
PokerScriptControlDescriptor scd = new PokerScriptControlDescriptor ("My.Type", "Element1");
scd.AddComponentProperty ("myName1", "myCompId1");
scd.AddComponentProperty ("myName2", "myCompId2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, null, null, {\"myName2\":\"myCompId2\",\"myName1\":\"myCompId1\"}, $get(\"Element1\"));", script);
#else
Assert.AreEqual ("$create(My.Type, null, null, {\"myName1\":\"myCompId1\",\"myName2\":\"myCompId2\"}, $get(\"Element1\"));", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptControlDescriptor_AddElementProperty () {
PokerScriptControlDescriptor scd = new PokerScriptControlDescriptor ("My.Type", "Element1");
scd.AddElementProperty ("myName1", "myElemId1");
scd.AddElementProperty ("myName2", "myElemId2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, {\"myName2\":$get(\"myElemId2\"),\"myName1\":$get(\"myElemId1\")}, null, null, $get(\"Element1\"));", script);
#else
Assert.AreEqual ("$create(My.Type, {\"myName1\":$get(\"myElemId1\"),\"myName2\":$get(\"myElemId2\")}, null, null, $get(\"Element1\"));", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptControlDescriptor_AddProperty () {
PokerScriptControlDescriptor scd = new PokerScriptControlDescriptor ("My.Type", "Element1");
scd.AddProperty ("myName1", "myValue1");
scd.AddProperty ("myName2", "myValue2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, {\"myName2\":\"myValue2\",\"myName1\":\"myValue1\"}, null, null, $get(\"Element1\"));", script);
#else
Assert.AreEqual ("$create(My.Type, {\"myName1\":\"myValue1\",\"myName2\":\"myValue2\"}, null, null, $get(\"Element1\"));", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptControlDescriptor_AddProperty_Null () {
PokerScriptControlDescriptor scd = new PokerScriptControlDescriptor ("My.Type", "Element1");
scd.AddProperty ("myName1", null);
scd.AddProperty ("myName2", null);
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, {\"myName2\":null,\"myName1\":null}, null, null, $get(\"Element1\"));", script);
#else
Assert.AreEqual ("$create(My.Type, {\"myName1\":null,\"myName2\":null}, null, null, $get(\"Element1\"));", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptControlDescriptor_AddEvent () {
PokerScriptControlDescriptor scd = new PokerScriptControlDescriptor ("My.Type", "Element1");
scd.AddEvent ("myName1", "myHandler1");
scd.AddEvent ("myName2", "myHandler2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, null, {\"myName2\":myHandler2,\"myName1\":myHandler1}, null, $get(\"Element1\"));", script);
#else
Assert.AreEqual ("$create(My.Type, null, {\"myName1\":myHandler1,\"myName2\":myHandler2}, null, $get(\"Element1\"));", script);
#endif
}
[Category("NotWorking")] // One must not depend on the order of keys in dictionary
[Test]
public void ScriptControlDescriptor_AddScriptProperty () {
PokerScriptControlDescriptor scd = new PokerScriptControlDescriptor ("My.Type", "Element1");
scd.AddScriptProperty ("myName1", "myScript1");
scd.AddScriptProperty ("myName2", "myScript2");
string script = scd.DoGetScript ();
#if TARGET_JVM
Assert.AreEqual ("$create(My.Type, {\"myName2\":myScript2,\"myName1\":myScript1}, null, null, $get(\"Element1\"));", script);
#else
Assert.AreEqual ("$create(My.Type, {\"myName1\":myScript1,\"myName2\":myScript2}, null, null, $get(\"Element1\"));", script);
#endif
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ScriptControlDescriptor_Type_exception_1 () {
PokerScriptControlDescriptor scd = new PokerScriptControlDescriptor ("My.Type", "Element1");
scd.Type = null;
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ScriptControlDescriptor_Type_exception_2 () {
PokerScriptControlDescriptor scd = new PokerScriptControlDescriptor ("My.Type", "Element1");
scd.Type = String.Empty;
}
[Test]
public void ScriptControlDescriptor_Type () {
PokerScriptControlDescriptor scd = new PokerScriptControlDescriptor ("My.Type", "Element1");
scd.Type = "New.Type";
Assert.AreEqual ("New.Type", scd.Type, "Type");
}
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void ScriptControlDescriptor_ID_set () {
PokerScriptControlDescriptor scd = new PokerScriptControlDescriptor ("My.Type", "Element1");
scd.ID = "My ID";
}
}
}

View File

@@ -0,0 +1,86 @@
//
// ScriptReferenceBaseTest.cs
//
// Author:
// Marek Habersack <mhabersack@novell.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.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.Text;
using NUnit.Framework;
using System.Web.UI;
namespace MonoTests.System.Web.UI
{
class MyScriptReference : ScriptReferenceBase
{
protected override string GetUrl (ScriptManager scriptManager, bool zip)
{
return null;
}
protected override bool IsFromSystemWebExtensions ()
{
return false;
}
public static string DoReplaceExtension (string path)
{
return ReplaceExtension (path);
}
}
[TestFixture]
public class ScriptReferenceBaseTest
{
[Test (Description="No checks are performed by .NET")]
[ExpectedException (typeof (NullReferenceException))]
public void ReplaceExtensionNullPath ()
{
MyScriptReference.DoReplaceExtension (null);
}
[Test (Description="No checks are performed by .NET")]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void ReplaceExtensionShortPath ()
{
MyScriptReference.DoReplaceExtension (String.Empty);
}
[Test]
public void ReplaceExtension ()
{
string ext = MyScriptReference.DoReplaceExtension ("js");
Assert.AreEqual ("debug.js", ext, "#1");
ext = MyScriptReference.DoReplaceExtension ("testjs");
Assert.AreEqual ("testdebug.js", ext, "#2");
ext = MyScriptReference.DoReplaceExtension ("test.js");
Assert.AreEqual ("test.debug.js", ext, "#3");
}
}
}

View File

@@ -0,0 +1,48 @@
//
// UpdateProgress.cs
//
// Author:
// Igor Zelmanovich <igorz@mainsoft.com>
//
// (C) 2007 Mainsoft, Inc. http://www.mainsoft.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.Text;
using NUnit.Framework;
using System.Web.UI;
namespace Tests.System.Web.UI
{
[TestFixture]
public class UpdateProgressTest
{
[Test]
public void UpdateProgress_Defaults () {
UpdateProgress up = new UpdateProgress ();
Assert.IsNotNull (((IScriptControl) up).GetScriptReferences ());
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
namespace Bug604053.Prueba {
public class Data {
public int M1 { get; set; }
public string M2 { get; set; }
public Data(int m1, string m2) {
M1 = m1;
M2 = m2;
}
}
[DataObject(true)]
public class DataSource {
public Data[] Retrieve() {
Data[] data = new Data[10];
for(int i = 0; i < 10; i++) {
data[i] = new Data(i, i.ToString());
}
return data;
}
}
}

View File

@@ -0,0 +1,4 @@
2008-11-19 Marek Habersack <mhabersack@novell.com>
* CountryCollection.cs, Country.cs: added

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace TestCode
{
public class Country
{
public Country(int id, string name, string capital, double population)
{
ID = id;
Name = name;
Capital = capital;
Population = population;
}
public int ID
{
get;
set;
}
public string Name
{
get;
set;
}
public string Capital
{
get;
set;
}
public double Population
{
get;
set;
}
}
}

View File

@@ -0,0 +1,131 @@
using System;
using System.Collections.Generic;
namespace TestCode
{
public class CountryCollection
{
static List<Country> db;
static CountryCollection()
{
db = new List<Country>();
db.Add(new Country(1, "Poland", "Warsaw", 38116000.0));
db.Add(new Country(2,"Portugal", "Lisbon", 10617575.0));
db.Add(new Country(3,"Australia", "Canberra", 21468700.0));
db.Add(new Country(4,"Austria", "Vienna", 8316487.0));
db.Add(new Country(5,"Belgium", "Brussels", 10666866.0));
db.Add(new Country(6,"Brazil", "Brasilia", 190132630.0));
db.Add(new Country(7,"China", "Bejing", 1321000000.0));
db.Add(new Country(8,"Chad", "N'Djamena", 10780600.0));
db.Add(new Country(9,"Venezuela", "Caracas", 28199822.0));
db.Add(new Country(10,"Vietnam", "Hanoi", 86116559.0));
db.Add(new Country(11,"New Zealand", "Wellington", 4268000.0));
db.Add(new Country(12,"Nigeria", "Abuja", 148000000.0));
db.Add(new Country(13,"Oman", "Muscat", 2577000.0));
db.Add(new Country(14,"Quatar", "Doha", 1450000.0));
db.Add(new Country(15,"Denmark", "Copenhagen", 5505995.0));
db.Add(new Country(16,"Dominican Republic", "Santo Domingo de Guzman", 9904000.0));
db.Add(new Country(17,"France", "Paris", 64473140.0));
db.Add(new Country(18,"United States of America", "Washington", 305619000.0));
db.Add(new Country(19,"Latvia", "Riga", 2270700.0));
}
public List<Country> GetCountries(string sortExpression)
{
var ret = new List<Country>();
ret.AddRange(db);
ret.Sort(new CountryComparer(sortExpression));
return ret;
}
public int Update(int id, string name, string capital, double population)
{
if (String.IsNullOrEmpty(name))
return 0;
int updated = 0;
foreach (Country c in db)
{
if (c.ID != id)
continue;
updated++;
c.Name = name;
c.Capital = capital;
c.Population = population;
}
return updated;
}
public int Insert(int id, string name, string capital, double population)
{
if (String.IsNullOrEmpty(name))
return 0;
db.Add(new Country(id, name, capital, population));
return 1;
}
public int Delete(int id)
{
var toDelete = new List<Country> ();
foreach (Country c in db)
{
if (c.ID != id)
continue;
toDelete.Add(c);
}
foreach (Country c in toDelete)
db.Remove(c);
return toDelete.Count;
}
}
sealed class CountryComparer : IComparer<Country>
{
string sortProperty;
bool descending;
public CountryComparer(string sortExpression)
{
descending = sortExpression.ToLowerInvariant().EndsWith(" desc");
if (descending)
{
sortProperty = sortExpression.Substring(0, sortExpression.Length - 5);
}
else
{
if (sortExpression.ToLowerInvariant().EndsWith(" asc"))
sortProperty = sortExpression.Substring(0, sortExpression.Length - 4);
else
sortProperty = sortExpression;
}
}
public int Compare(Country a, Country b)
{
int retVal = 0;
switch (sortProperty)
{
case "Name":
retVal = String.Compare(a.Name, b.Name, StringComparison.InvariantCultureIgnoreCase);
break;
case "Capital":
retVal = String.Compare(a.Capital, b.Capital, StringComparison.InvariantCultureIgnoreCase);
break;
case "Population":
retVal = (int)(a.Population - b.Population);
break;
}
if (descending)
return retVal;
return retVal * -1;
}
}
}

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