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,83 @@
//
// CategoryNameCollectionCas.cs
// - CAS unit tests for System.Drawing.Design.CategoryNameCollection
//
// 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.Drawing.Design;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
namespace MonoCasTests.System.Drawing.Design {
[TestFixture]
[Category ("CAS")]
public class CategoryNameCollectionCas {
private ConstructorInfo ctor;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
// this executes at fulltrust
ConstructorInfo[] infos = typeof (CategoryNameCollection).GetConstructors ();
ctor = infos[0];
}
[SetUp]
public void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Create ()
{
new CategoryNameCollection (new string[0]);
}
// we use reflection to call CategoryNameCollection class as it's
// protected by a LinkDemand (which will be converted into full demand,
// i.e. a stack walk) when reflection is used (i.e. it gets testable).
[Test]
[SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
[ExpectedException (typeof (SecurityException))]
public void Create_LinkDemand ()
{
// requires FullTrust, so denying anything break the requirements
Assert.IsNotNull (ctor, "constructor");
ctor.Invoke (new object[1] { (string[])null });
}
}
}

View File

@@ -0,0 +1,39 @@
2006-12-21 Sebastien Pouliot <sebastien@ximian.com>
* TestToolboxItem.cs: More test cases (mostly 2.0 stuff).
2006-11-28 Sebastien Pouliot <sebastien@ximian.com>
* UITypeEditorCas.cs: Reuse new unit test cases in CAS tests.
* UITypeEditorTest.cs: New. Unit tests for UITypeEditor.
2006-05-25 Gert Driesen <drieseng@users.sourceforge.net>
* PropertyValueUIItemCas.cs: Fix compilation using csc 1.x.
2006-05-24 Sebastien Pouliot <sebastien@ximian.com>
* TestToolboxItem.cs: Update ComponentType check to work under MS 2.0.
2005-12-05 Jordi Mas i Hernandez <jordimash@gmail.com>
* TestToolboxItem.cs: New unit test
2005-09-16 Sebastien Pouliot <sebastien@ximian.com>
* CategoryNameCollectionCas.cs: New. CAS unit tests to check for
LinkDemand for SkipVerification.
* PaintValueEventArgsCas.cs: New. CAS unit tests to check for
LinkDemand for SkipVerification.
* PropertyValueUIItemCas.cs: New. CAS unit tests to check for
LinkDemand for SkipVerification.
* ToolboxComponentsCreatedEventArgsCas.cs: New. CAS unit tests to
check for LinkDemand for SkipVerification.
* ToolboxComponentsCreatingEventArgsCas.cs: New. CAS unit tests to
check for LinkDemand for SkipVerification.
* ToolboxItemCas.cs: New. CAS unit tests to check for LinkDemand for
SkipVerification.
* ToolboxItemCollectionCas.cs: New. CAS unit tests to check for
LinkDemand for SkipVerification.
* UITypeEditorCas.cs: New. CAS unit tests to check for LinkDemand for
SkipVerification.

View File

@@ -0,0 +1,85 @@
//
// PaintValueEventArgsCas.cs
// - CAS unit tests for System.Drawing.Design.PaintValueEventArgs
//
// 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.Drawing;
using System.Drawing.Design;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
namespace MonoCasTests.System.Drawing.Design {
[TestFixture]
[Category ("CAS")]
public class PaintValueEventArgsCas {
private ConstructorInfo ctor;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
// this executes at fulltrust
ConstructorInfo[] infos = typeof (PaintValueEventArgs).GetConstructors ();
ctor = infos[0];
}
[SetUp]
public void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Create ()
{
Rectangle r = new Rectangle ();
new PaintValueEventArgs (null, null, Graphics.FromImage (new Bitmap (10, 10)), r);
}
// we use reflection to call PaintValueEventArgs class as it's protected
// by a LinkDemand (which will be converted into full demand, i.e. a
// stack walk) when reflection is used (i.e. it gets testable).
[Test]
[SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
[ExpectedException (typeof (SecurityException))]
public void Create_LinkDemand ()
{
// requires FullTrust, so denying anything break the requirements
Assert.IsNotNull (ctor, "constructor");
ctor.Invoke (new object[4]);
}
}
}

View File

@@ -0,0 +1,89 @@
//
// PropertyValueUIItemCas.cs
// - CAS unit tests for System.Drawing.Design.PropertyValueUIItem
//
// 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.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
namespace MonoCasTests.System.Drawing.Design {
[TestFixture]
[NUnit.Framework.Category ("CAS")]
public class PropertyValueUIItemCas {
private ConstructorInfo ctor;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
// this executes at fulltrust
ConstructorInfo[] infos = typeof (PropertyValueUIItem).GetConstructors ();
ctor = infos[0];
}
[SetUp]
public void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
}
private void PropertyValueUIItemInvoke (ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem)
{
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Create ()
{
new PropertyValueUIItem (new Bitmap (10, 10), new PropertyValueUIItemInvokeHandler(PropertyValueUIItemInvoke), null);
}
// we use reflection to call PropertyValueUIItem class as it's protected
// by a LinkDemand (which will be converted into full demand, i.e. a stack
// walk) when reflection is used (i.e. it gets testable).
[Test]
[SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
[ExpectedException (typeof (SecurityException))]
public void Create_LinkDemand ()
{
// requires FullTrust, so denying anything break the requirements
Assert.IsNotNull (ctor, "constructor");
ctor.Invoke (new object [3]);
}
}
}

View File

@@ -0,0 +1,450 @@
//
// Copyright (C) 2004-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.
//
// Authors:
//
// Jordi Mas i Hernandez, jordimash@gmail.com
//
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Reflection;
using System.Drawing;
using System.Drawing.Design;
using NUnit.Framework;
namespace MonoTests.System.Drawing.Design {
[TestFixture]
public class TestToolboxItem {
private AssemblyName an;
private Bitmap bitmap;
private ToolboxItemFilterAttribute[] filter;
private AssemblyName[] dependent;
class OurToolboxItem: ToolboxItem {
public OurToolboxItem ()
{
}
public void _CheckUnlocked ()
{
CheckUnlocked ();
}
public Type _GetType (IDesignerHost host, AssemblyName an, string tn, bool r)
{
return GetType (host, an, tn, r);
}
#if NET_2_0
public object Filter (string propertyName, object value)
{
return FilterPropertyValue (propertyName, value);
}
public void _ValidatePropertyType (string propertyName, object value, Type expectedType, bool allowNull)
{
ValidatePropertyType (propertyName, value, expectedType, allowNull);
}
public object _ValidatePropertyValue (string propertyName, object value)
{
return ValidatePropertyValue (propertyName, value);
}
#endif
}
[TestFixtureSetUp]
public void FixtureSetUp ()
{
bitmap = new Bitmap (20, 20);
an = new AssemblyName ();
filter = new ToolboxItemFilterAttribute[0];
dependent = new AssemblyName[0];
}
[Test]
public void DefaultValues ()
{
ToolboxItem item = new ToolboxItem ();
Assert.IsNull (item.AssemblyName, "AssemblyName");
Assert.IsNull (item.Bitmap, "Bitmap");
Assert.AreEqual (String.Empty, item.DisplayName, "DisplayName");
Assert.AreEqual (typeof (ToolboxItemFilterAttribute[]), item.Filter.GetType (), "Filter/Type");
Assert.AreEqual (0, item.Filter.Count, "Filter");
Assert.AreEqual (String.Empty, item.TypeName, "TypeName");
#if NET_2_0
Assert.IsNull (item.Company, "Company");
Assert.AreEqual (".NET Component", item.ComponentType, "ComponentType");
Assert.IsNull (item.DependentAssemblies, "DependentAssemblies");
Assert.IsNull (item.Description, "Description");
Assert.IsFalse (item.IsTransient, "IsTransient");
Assert.AreEqual (0, item.Properties.Count, "Properties");
Assert.AreEqual (String.Empty, item.Version, "Version");
#endif
}
[Test]
public void NullValues ()
{
ToolboxItem item = new ToolboxItem ();
item.AssemblyName = null;
Assert.IsNull (item.AssemblyName, "AssemblyName");
item.Bitmap = null;
Assert.IsNull (item.Bitmap, "Bitmap");
item.DisplayName = null;
Assert.AreEqual (String.Empty, item.DisplayName, "DisplayName");
item.Filter = null;
Assert.AreEqual (0, item.Filter.Count, "Filter");
item.TypeName = null;
Assert.AreEqual (String.Empty, item.TypeName, "TypeName");
#if NET_2_0
item.Company = null;
Assert.AreEqual (String.Empty, item.Company, "Company");
// can't assign null without a NRE
item.DependentAssemblies = new AssemblyName [0];
Assert.AreEqual (0, item.DependentAssemblies.Length, "DependentAssemblies");
item.Description = null;
Assert.AreEqual (String.Empty, item.Description, "Description");
item.IsTransient = true;
Assert.IsTrue (item.IsTransient, "IsTransient");
Assert.AreEqual (9, item.Properties.Count, "Properties");
item.Lock ();
Assert.AreEqual (9, item.Properties.Count, "Properties/Lock");
#endif
}
[Test]
public void TestProperties ()
{
ToolboxItem item = new ToolboxItem ();
AssemblyName name = new AssemblyName ();
name.Name = "OurAssembly";
item.AssemblyName = name;
Assert.AreEqual (name.Name.ToString (), "OurAssembly", "TP#1");
item.TypeName = "TypeName1";
Assert.AreEqual ("TypeName1", item.TypeName, "TP#2");
item.DisplayName = "ShowName";
Assert.AreEqual (item.DisplayName, "ShowName", "TP#3");
item.TypeName = "TypeNameSt";
Assert.AreEqual (item.TypeName, "TypeNameSt", "TP#4");
Bitmap bmp = new Bitmap (200, 200);
item.Bitmap = bmp;
Assert.AreEqual (bmp, item.Bitmap, "TP#5");
}
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void TestCheckUnlocked1 ()
{
OurToolboxItem item = new OurToolboxItem ();
item.Lock ();
item._CheckUnlocked ();
}
[Test]
public void TestCheckUnlocked2 ()
{
OurToolboxItem item = new OurToolboxItem ();
item._CheckUnlocked ();
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void GetType_Null_Null_Null_False ()
{
new OurToolboxItem ()._GetType (null, null, null, false);
}
[Test]
public void GetType_Null_Null_String_False ()
{
OurToolboxItem item = new OurToolboxItem ();
Assert.IsNull (item._GetType (null, null, "string", false), "GetType");
}
[Test]
public void Initialize_Null ()
{
ToolboxItem item = new ToolboxItem ();
item.Initialize (null);
}
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void Initialize_Locked_Null ()
{
ToolboxItem item = new ToolboxItem ();
item.Lock ();
item.Initialize (null);
}
[Test]
public void Locked_Twice ()
{
ToolboxItem item = new ToolboxItem ();
item.Lock ();
item.Lock ();
}
#if NET_2_0
[Test]
public void TestNewProperties ()
{
ToolboxItem item = new ToolboxItem ();
item.Company = "OurCompany";
Assert.AreEqual ("OurCompany", item.Company, "TNP#1");
Assert.AreEqual (".NET Component", item.ComponentType, "TNP#2");
item.Description = "Description";
Assert.AreEqual ("Description", item.Description, "TNP#3");
item.IsTransient = true;
Assert.AreEqual (true, item.IsTransient, "TNP#4");
}
[Test]
[ExpectedException (typeof (NullReferenceException))]
public void DependentAssemblies_Null ()
{
new ToolboxItem ().DependentAssemblies = null;
}
[Test]
public void DependentAssemblies_Empty ()
{
ToolboxItem item = new ToolboxItem ();
item.DependentAssemblies = new AssemblyName[0];
Assert.AreEqual (0, item.DependentAssemblies.Length, "Length");
}
[Test]
public void DependentAssemblies ()
{
AssemblyName[] names = new AssemblyName [1];
names[0] = new AssemblyName ();
ToolboxItem item = new ToolboxItem ();
item.DependentAssemblies = names;
Assert.AreEqual (1, item.DependentAssemblies.Length, "Length");
Assert.IsTrue (Object.ReferenceEquals (names[0], item.DependentAssemblies[0]), "ReferenceEquals");
names[0] = null;
Assert.IsNotNull (item.DependentAssemblies[0], "0");
}
[Test]
public void Filter ()
{
OurToolboxItem item = new OurToolboxItem ();
Assert.IsNull (item.Filter ("AssemblyName", null), "AssemblyName,null");
// they are "equal" (publicly wise) but have a different hash code
Assert.AreEqual (typeof (AssemblyName), item.Filter ("AssemblyName", an).GetType (), "AssemblyName,an");
Assert.IsNull (item.Filter ("Bitmap", null), "Bitmap,null");
Assert.AreSame (bitmap, item.Filter ("Bitmap", bitmap), "Bitmap,bitmap");
Assert.AreEqual (String.Empty, item.Filter ("DisplayName", null), "DisplayName,null");
Assert.AreSame (String.Empty, item.Filter ("DisplayName", String.Empty), "DisplayName,string");
Assert.AreEqual (filter, item.Filter ("Filter", null), "Filter,null");
Assert.AreSame (filter, item.Filter ("Filter", filter), "Filter,ToolboxItemFilterAttribute[]");
Assert.AreEqual (String.Empty, item.Filter ("TypeName", null), "TypeName,null");
Assert.AreSame (String.Empty, item.Filter ("TypeName", String.Empty), "TypeName,string");
Assert.IsNull (item.Filter ("Company", null), "Company,null");
Assert.AreSame (String.Empty, item.Filter ("Company", String.Empty), "Company,string");
Assert.AreEqual (null, item.Filter ("DependentAssemblies", null), "DependentAssemblies,null");
// note: not same
Assert.AreEqual (dependent, item.Filter ("DependentAssemblies", filter), "DependentAssemblies,AssemblyName[]");
Assert.IsFalse (Object.ReferenceEquals (dependent, item.Filter ("DependentAssemblies", filter)), "DependentAssemblies,AssemblyName[]/Reference");
Assert.IsNull (item.Filter ("Description", null), "Description,null");
Assert.AreSame (String.Empty, item.Filter ("Description", String.Empty), "Description,string");
Assert.IsTrue ((bool) item.Filter ("IsTransient", true), "IsTransient,true");
Assert.IsFalse ((bool) item.Filter ("IsTransient", false), "IsTransient,false");
}
[Test]
public void GetType_Null ()
{
ToolboxItem item = new ToolboxItem ();
Assert.IsNull (item.GetType (null), "GetType(null)");
}
[Test]
public void ValidatePropertyType ()
{
OurToolboxItem item = new OurToolboxItem ();
item._ValidatePropertyType ("IsTransient", true, typeof (bool), false);
item._ValidatePropertyType ("IsTransient", String.Empty, typeof (string), false);
}
[Test]
[ExpectedException (typeof (NullReferenceException))]
public void ValidatePropertyType_Type_Null ()
{
OurToolboxItem item = new OurToolboxItem ();
item._ValidatePropertyType ("IsTransient", true, null, false);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ValidatePropertyType_IsTransient_WrongType ()
{
OurToolboxItem item = new OurToolboxItem ();
item._ValidatePropertyType ("IsTransient", new object (), typeof (bool), false);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ValidatePropertyType_DontAllowNull ()
{
OurToolboxItem item = new OurToolboxItem ();
item._ValidatePropertyType ("IsTransient", null, typeof (bool), false);
}
[Test]
public void ValidatePropertyValue ()
{
OurToolboxItem item = new OurToolboxItem ();
object o = new object ();
Assert.IsNull (item._ValidatePropertyValue (null, null), "null,null");
Assert.AreSame (o, item._ValidatePropertyValue (null, o), "null,object");
Assert.IsNull (item._ValidatePropertyValue ("string", null), "string,null");
Assert.AreSame (o, item._ValidatePropertyValue ("string", o), "string,object");
Assert.IsNull (item._ValidatePropertyValue ("AssemblyName", null), "AssemblyName,null");
Assert.AreSame (an, item._ValidatePropertyValue ("AssemblyName", an), "AssemblyName,an");
Assert.IsNull (item._ValidatePropertyValue ("Bitmap", null), "Bitmap,null");
Assert.AreSame (bitmap, item._ValidatePropertyValue ("Bitmap", bitmap), "Bitmap,bitmap");
Assert.AreEqual (String.Empty, item._ValidatePropertyValue ("DisplayName", null), "DisplayName,null");
Assert.AreSame (String.Empty, item._ValidatePropertyValue ("DisplayName", String.Empty), "DisplayName,string");
Assert.AreEqual (filter, item._ValidatePropertyValue ("Filter", null), "Filter,null");
Assert.AreEqual (filter, item._ValidatePropertyValue ("Filter", filter), "Filter,ToolboxItemFilterAttribute[]");
//Assert.IsFalse (Object.ReferenceEquals (filter, item._ValidatePropertyValue ("Filter", filter)), "Filter,ToolboxItemFilterAttribute[]/Reference");
Assert.AreEqual (String.Empty, item._ValidatePropertyValue ("TypeName", null), "TypeName,null");
Assert.AreSame (String.Empty, item._ValidatePropertyValue ("TypeName", String.Empty), "TypeName,string");
Assert.AreEqual (String.Empty, item._ValidatePropertyValue ("Company", null), "Company,null");
Assert.AreSame (String.Empty, item._ValidatePropertyValue ("Company", String.Empty), "Company,string");
Assert.AreEqual (null, item._ValidatePropertyValue ("DependentAssemblies", null), "DependentAssemblies,null");
Assert.AreEqual (dependent, item._ValidatePropertyValue ("DependentAssemblies", dependent), "DependentAssemblies,AssemblyName[]");
Assert.IsTrue (Object.ReferenceEquals (dependent, item._ValidatePropertyValue ("DependentAssemblies", dependent)), "DependentAssemblies,AssemblyName[]/Reference");
Assert.AreEqual (String.Empty, item._ValidatePropertyValue ("Description", null), "Description,null");
Assert.AreSame (String.Empty, item._ValidatePropertyValue ("Description", String.Empty), "Description,string");
Assert.IsTrue ((bool)item._ValidatePropertyValue ("IsTransient", true), "IsTransient,true");
Assert.IsFalse ((bool)item._ValidatePropertyValue ("IsTransient", false), "IsTransient,false");
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ValidatePropertyValue_AssemblyName_WrongType ()
{
OurToolboxItem item = new OurToolboxItem ();
item._ValidatePropertyValue ("AssemblyName", false);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ValidatePropertyValue_Bitmap_WrongType ()
{
OurToolboxItem item = new OurToolboxItem ();
item._ValidatePropertyValue ("Bitmap", false);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ValidatePropertyValue_DisplayName_WrongType ()
{
OurToolboxItem item = new OurToolboxItem ();
item._ValidatePropertyValue ("DisplayName", false);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ValidatePropertyValue_Filter_WrongType ()
{
OurToolboxItem item = new OurToolboxItem ();
item._ValidatePropertyValue ("Filter", false);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ValidatePropertyValue_TypeName_WrongType ()
{
OurToolboxItem item = new OurToolboxItem ();
item._ValidatePropertyValue ("TypeName", false);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ValidatePropertyValue_Company_WrongType ()
{
OurToolboxItem item = new OurToolboxItem ();
item._ValidatePropertyValue ("Company", false);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ValidatePropertyValue_Description_WrongType ()
{
OurToolboxItem item = new OurToolboxItem ();
item._ValidatePropertyValue ("Description", false);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ValidatePropertyValue_IsTransient_Null ()
{
// only documented case
new OurToolboxItem ()._ValidatePropertyValue ("IsTransient", null);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ValidatePropertyValue_IsTransient_WrongType ()
{
// only documented case
new OurToolboxItem ()._ValidatePropertyValue ("IsTransient", new object ());
}
#endif
}
}

View File

@@ -0,0 +1,83 @@
//
// ToolboxComponentsCreatedEventArgsCas.cs - CAS unit tests
// for System.Drawing.Design.ToolboxComponentsCreatedEventArgs
//
// 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.Drawing.Design;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
namespace MonoCasTests.System.Drawing.Design {
[TestFixture]
[Category ("CAS")]
public class ToolboxComponentsCreatedEventArgsCas {
private ConstructorInfo ctor;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
// this executes at fulltrust
ConstructorInfo[] infos = typeof (ToolboxComponentsCreatedEventArgs).GetConstructors ();
ctor = infos[0];
}
[SetUp]
public void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Create ()
{
new ToolboxComponentsCreatedEventArgs (null);
}
// we use reflection to call ToolboxComponentsCreatedEventArgs class as
// it's protected by a LinkDemand (which will be converted into full demand,
// i.e. a stack walk) when reflection is used (i.e. it gets testable).
[Test]
[SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
[ExpectedException (typeof (SecurityException))]
public void Create_LinkDemand ()
{
// requires FullTrust, so denying anything break the requirements
Assert.IsNotNull (ctor, "constructor");
ctor.Invoke (new object[1] { null });
}
}
}

View File

@@ -0,0 +1,83 @@
//
// ToolboxComponentsCreatingEventArgsCas.cs - CAS unit tests
// for System.Drawing.Design.ToolboxComponentsCreatingEventArgs
//
// 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.Drawing.Design;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
namespace MonoCasTests.System.Drawing.Design {
[TestFixture]
[Category ("CAS")]
public class ToolboxComponentsCreatingEventArgsCas {
private ConstructorInfo ctor;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
// this executes at fulltrust
ConstructorInfo[] infos = typeof (ToolboxComponentsCreatingEventArgs).GetConstructors ();
ctor = infos[0];
}
[SetUp]
public void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Create ()
{
new ToolboxComponentsCreatingEventArgs (null);
}
// we use reflection to call ToolboxComponentsCreatingEventArgs class as
// it's protected by a LinkDemand (which will be converted into full demand,
// i.e. a stack walk) when reflection is used (i.e. it gets testable).
[Test]
[SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
[ExpectedException (typeof (SecurityException))]
public void Create_LinkDemand ()
{
// requires FullTrust, so denying anything break the requirements
Assert.IsNotNull (ctor, "constructor");
ctor.Invoke (new object[1] { null });
}
}
}

View File

@@ -0,0 +1,82 @@
//
// ToolboxItemCas.cs - CAS unit tests for System.Drawing.Design.ToolboxItem
//
// 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.Drawing.Design;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
namespace MonoCasTests.System.Drawing.Design {
[TestFixture]
[Category ("CAS")]
public class ToolboxItemCas {
private ConstructorInfo ctor;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
// this executes at fulltrust
ConstructorInfo[] infos = typeof (ToolboxItem).GetConstructors ();
ctor = infos[0];
}
[SetUp]
public void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Create ()
{
new ToolboxItem ();
}
// we use reflection to call ToolboxItem class as it's protected by a
// LinkDemand (which will be converted into full demand, i.e. a stack
// walk) when reflection is used (i.e. it gets testable).
[Test]
[SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
[ExpectedException (typeof (SecurityException))]
public void Create_LinkDemand ()
{
// requires FullTrust, so denying anything break the requirements
Assert.IsNotNull (ctor, "constructor");
ctor.Invoke (null);
}
}
}

View File

@@ -0,0 +1,83 @@
//
// ToolboxItemCollectionCas.cs
// - CAS unit tests for System.Drawing.Design.ToolboxItemCollection
//
// 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.Drawing.Design;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
namespace MonoCasTests.System.Drawing.Design {
[TestFixture]
[Category ("CAS")]
public class ToolboxItemCollectionCas {
private ConstructorInfo ctor;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
// this executes at fulltrust
ConstructorInfo[] infos = typeof (ToolboxItemCollection).GetConstructors ();
ctor = infos[0];
}
[SetUp]
public void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Create ()
{
new ToolboxItemCollection (new ToolboxItem [0]);
}
// we use reflection to call ToolboxItemCollection class as it's protected
// by a LinkDemand (which will be converted into full demand, i.e. a stack
// walk) when reflection is used (i.e. it gets testable).
[Test]
[SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
[ExpectedException (typeof (SecurityException))]
public void Create_LinkDemand ()
{
// requires FullTrust, so denying anything break the requirements
Assert.IsNotNull (ctor, "constructor");
ctor.Invoke (new object[1] { new ToolboxItem[0] });
}
}
}

View File

@@ -0,0 +1,106 @@
//
// UITypeEditorCas.cs - CAS unit tests for System.Drawing.Design.UITypeEditor
//
// 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.Drawing.Design;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
using MonoTests.System.Drawing.Design;
namespace MonoCasTests.System.Drawing.Design {
[TestFixture]
[Category ("CAS")]
public class UITypeEditorCas {
private ConstructorInfo ctor;
private UITypeEditorTest unit;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
// this executes at fulltrust
ConstructorInfo[] infos = typeof (UITypeEditor).GetConstructors ();
ctor = infos[0];
unit = new UITypeEditorTest ();
unit.FixtureSetUp ();
}
[SetUp]
public void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Create ()
{
new UITypeEditor ();
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void UnitTests ()
{
unit.DefaultValues ();
}
#if !TARGET_JVM
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void UnitTests_PaintValue ()
{
unit.PaintValue_PaintValueEventArgs_Null ();
unit.PaintValue_PaintValueEventArgs ();
unit.PaintValue ();
}
#endif
// we use reflection to call UITypeEditor class as it's protected by a
// LinkDemand (which will be converted into full demand, i.e. a stack
// walk) when reflection is used (i.e. it gets testable).
[Test]
[SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
[ExpectedException (typeof (SecurityException))]
public void Create_LinkDemand ()
{
// requires FullTrust, so denying anything break the requirements
Assert.IsNotNull (ctor, "constructor");
ctor.Invoke (null);
}
}
}

View File

@@ -0,0 +1,88 @@
//
// UITypeEditorTest.cs - Unit tests for System.Drawing.Design.UITypeEditor
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2006 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.Drawing;
using System.Drawing.Design;
namespace MonoTests.System.Drawing.Design {
[TestFixture]
public class UITypeEditorTest {
private UITypeEditor editor;
private Graphics graphics;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
editor = new UITypeEditor ();
Bitmap bitmap = new Bitmap (20, 20);
graphics = Graphics.FromImage (bitmap);
}
[Test]
public void DefaultValues ()
{
Assert.AreSame (graphics, editor.EditValue (null, graphics), "EditValue(2)");
Assert.AreSame (graphics, editor.EditValue (null, null, graphics), "EditValue(3)");
Assert.AreEqual (UITypeEditorEditStyle.None, editor.GetEditStyle (), "GetEditStyle()");
Assert.AreEqual (UITypeEditorEditStyle.None, editor.GetEditStyle (null), "GetEditStyle(null)");
Assert.IsFalse (editor.GetPaintValueSupported (), "GetPaintValueSupported()");
Assert.IsFalse (editor.GetPaintValueSupported (null), "GetPaintValueSupported(null)");
#if NET_2_0
Assert.IsFalse (editor.IsDropDownResizable, "IsDropDownResizable");
#endif
}
#if !TARGET_JVM
[Test]
public void PaintValue_PaintValueEventArgs_Null ()
{
editor.PaintValue (null);
}
[Test]
public void PaintValue_PaintValueEventArgs ()
{
editor.PaintValue (new PaintValueEventArgs (null, null, graphics, Rectangle.Empty));
}
[Test]
public void PaintValue ()
{
editor.PaintValue (null, graphics, Rectangle.Empty);
}
#endif
}
}