You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
committed by
Jo Shields
parent
aa7da660d6
commit
c042cd0c52
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MonoTests.System.Windows.Forms
|
||||
{
|
||||
[TestFixture]
|
||||
public class ControlCollectionTest : TestHelper
|
||||
{
|
||||
[Test]
|
||||
public void ControlCollectionTests ()
|
||||
{
|
||||
Control c = new Control ();
|
||||
c.Name = "A";
|
||||
Control c2 = new Control ();
|
||||
c2.Name = "B";
|
||||
Control c3 = new Control ();
|
||||
c3.Name = "a";
|
||||
Control c4 = new Control ();
|
||||
c4.Name = "B";
|
||||
Control c5 = new Control ();
|
||||
c5.Name = "a";
|
||||
|
||||
c.Controls.Add (c2);
|
||||
c.Controls.Add (c3);
|
||||
c2.Controls.Add (c4);
|
||||
c2.Controls.Add (c5);
|
||||
|
||||
// this[key]
|
||||
Assert.AreSame (c2, c.Controls["B"], "A1");
|
||||
Assert.AreSame (c2, c.Controls["b"], "A2");
|
||||
|
||||
// Owner
|
||||
Assert.AreSame (c, c.Controls.Owner, "A3");
|
||||
|
||||
// ContainsKey
|
||||
Assert.AreEqual (true, c.Controls.ContainsKey ("A"), "A4");
|
||||
Assert.AreEqual (true, c.Controls.ContainsKey ("a"), "A5");
|
||||
Assert.AreEqual (false, c.Controls.ContainsKey ("C"), "A6");
|
||||
|
||||
// Find
|
||||
Assert.AreEqual (1, c.Controls.Find ("A", false).Length, "A7");
|
||||
Assert.AreEqual (1, c.Controls.Find ("a", false).Length, "A8");
|
||||
Assert.AreEqual (0, c.Controls.Find ("C", false).Length, "A9");
|
||||
|
||||
Assert.AreEqual (2, c.Controls.Find ("A", true).Length, "A10");
|
||||
Assert.AreEqual (2, c.Controls.Find ("a", true).Length, "A11");
|
||||
Assert.AreEqual (0, c.Controls.Find ("C", true).Length, "A12");
|
||||
Assert.AreEqual (1, c2.Controls.Find ("b", true).Length, "A13");
|
||||
|
||||
// IndexOfKey
|
||||
Assert.AreEqual (1, c.Controls.IndexOfKey ("A"), "A14");
|
||||
Assert.AreEqual (1, c.Controls.IndexOfKey ("a"), "A15");
|
||||
Assert.AreEqual (-1, c.Controls.IndexOfKey ("C"), "A16");
|
||||
|
||||
// RemoveByKey
|
||||
c.Controls.RemoveByKey ("A");
|
||||
Assert.AreEqual (1, c.Controls.Count, "A17");
|
||||
|
||||
c.Controls.RemoveByKey ("b");
|
||||
Assert.AreEqual (0, c.Controls.Count, "A18");
|
||||
|
||||
c.Controls.RemoveByKey (null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentNullException))]
|
||||
public void ControlCollectionFindANE ()
|
||||
{
|
||||
Control c = new Control ();
|
||||
c.Controls.Find ("", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user