| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- // 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.
- //
- // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
- //
- // Author:
- // Jordi Mas i Hernandez <[email protected]>
- //
- //
- using System;
- using System.Windows.Forms;
- using System.Drawing;
- using System.Reflection;
- using System.Collections;
- using NUnit.Framework;
- namespace MonoTests.System.Windows.Forms
- {
- [TestFixture]
- public class ListViewCollectionsTest
- {
- /*
- ColumnHeaderCollection
- */
- [Test]
- public void ColumnHeaderCollectionTest_PropertiesTest ()
- {
- ListView listview = new ListView ();
- // Properties
- Assert.AreEqual (false, listview.Columns.IsReadOnly, "ColumnHeaderCollectionTest_PropertiesTest#1");
- Assert.AreEqual (true, ((ICollection)listview.Columns).IsSynchronized, "ColumnHeaderCollectionTest_PropertiesTest#2");
- Assert.AreEqual (listview.Columns, ((ICollection)listview.Columns).SyncRoot, "ColumnHeaderCollectionTest_PropertiesTest#3");
- Assert.AreEqual (false, ((IList)listview.Columns).IsFixedSize, "ColumnHeaderCollectionTest_PropertiesTest#4");
- Assert.AreEqual (0, listview.Columns.Count, "ColumnHeaderCollectionTest_PropertiesTest#5");
- }
- [Test]
- public void ColumnHeaderCollectionTest_AddTest ()
- {
- ListView listview = new ListView ();
- // Duplicated elements with same text added
- listview.Columns.Add (new ColumnHeader ());
- listview.Columns.Add (new ColumnHeader ());
- Assert.AreEqual (2, listview.Columns.Count, "ColumnHeaderCollectionTest_AddTest#1");
- Assert.AreEqual ("ColumnHeader", listview.Columns[0].Text, "ColumnHeaderCollectionTest_AddTest#2");
- }
- [Test]
- public void ColumnHeaderCollectionTest_ClearTest ()
- {
- ListView listview = new ListView ();
- // Duplicated elements with same text added
- listview.Columns.Add (new ColumnHeader ());
- listview.Columns.Clear ();
- Assert.AreEqual (0, listview.Columns.Count, "ColumnHeaderCollectionTest_ClearTest#1");
- }
- // Exceptions
- [Test, ExpectedException (typeof (ArgumentOutOfRangeException))]
- public void ColumnHeaderCollectionTest_GetItem_ExceptionTest ()
- {
- // Duplicated elements not added
- ListView listview = new ListView ();
- ColumnHeader item = listview.Columns[5];
- }
- /*
- CheckedIndexCollection
- */
- [Test]
- public void CheckedIndexCollectionTest_PropertiesTest ()
- {
- ListView listview = new ListView ();
- // Properties
- Assert.AreEqual (true, listview.CheckedIndices.IsReadOnly, "CheckedIndexCollectionTest_PropertiesTest#1");
- Assert.AreEqual (false, ((ICollection)listview.CheckedIndices).IsSynchronized, "CheckedIndexCollectionTest_PropertiesTest#2");
- Assert.AreEqual (listview.CheckedIndices, ((ICollection)listview.CheckedIndices).SyncRoot, "CheckedIndexCollectionTest_PropertiesTest#3");
- Assert.AreEqual (true, ((IList)listview.CheckedIndices).IsFixedSize, "CheckedIndexCollectionTest_PropertiesTest#4");
- Assert.AreEqual (0, listview.CheckedIndices.Count, "CheckedIndexCollectionTest_PropertiesTest#5");
- }
- // Exceptions
- [Test, ExpectedException (typeof (NotSupportedException))]
- public void CheckedIndexCollectionTest_Add_ExceptionTest ()
- {
- ListView listview = new ListView ();
- ((IList)listview.CheckedIndices).Add (5);
- }
- [Test, ExpectedException (typeof (NotSupportedException))]
- public void CheckedIndexCollectionTest_Remove_ExceptionTest ()
- {
- ListView listview = new ListView ();
- ((IList)listview.CheckedIndices).Remove (5);
- }
- [Test, ExpectedException (typeof (NotSupportedException))]
- public void CheckedIndexCollectionTest_RemoveAt_ExceptionTest ()
- {
- ListView listview = new ListView ();
- ((IList)listview.CheckedIndices).RemoveAt (5);
- }
- /*
- CheckedItemCollection
- */
- [Test]
- public void CheckedItemCollectionTest_PropertiesTest ()
- {
- ListView listview = new ListView ();
- // Properties
- Assert.AreEqual (true, listview.CheckedItems.IsReadOnly, "CheckedItemCollectionTest_PropertiesTest#1");
- Assert.AreEqual (false, ((ICollection)listview.CheckedItems).IsSynchronized, "CheckedItemCollectionTest_PropertiesTest#2");
- Assert.AreEqual (listview.CheckedItems, ((ICollection)listview.CheckedItems).SyncRoot, "CheckedItemCollectionTest_PropertiesTest#3");
- Assert.AreEqual (true, ((IList)listview.CheckedItems).IsFixedSize, "CheckedItemCollectionTest_PropertiesTest#4");
- Assert.AreEqual (0, listview.CheckedItems.Count, "CheckedItemCollectionTest_PropertiesTest#5");
- }
- // Exceptions
- [Test, ExpectedException (typeof (NotSupportedException))]
- public void CheckedItemCollectionTest_PropertiesTest_Add_ExceptionTest ()
- {
- ListView listview = new ListView ();
- ((IList)listview.CheckedItems).Add (5);
- }
- [Test, ExpectedException (typeof (NotSupportedException))]
- public void CheckedItemCollectionTest_PropertiesTest_Remove_ExceptionTest ()
- {
- ListView listview = new ListView ();
- ((IList)listview.CheckedItems).Remove (5);
- }
- [Test, ExpectedException (typeof (NotSupportedException))]
- public void CheckedItemCollectionTest_PropertiesTest_RemoveAt_ExceptionTest ()
- {
- ListView listview = new ListView ();
- ((IList)listview.CheckedItems).RemoveAt (5);
- }
- /*
- SelectedIndexCollection
- */
- [Test]
- public void SelectedIndexCollectionTest_PropertiesTest ()
- {
- ListView listview = new ListView ();
- // Properties
- Assert.AreEqual (true, listview.SelectedIndices.IsReadOnly, "SelectedIndexCollectionTest_PropertiesTest#1");
- Assert.AreEqual (false, ((ICollection)listview.SelectedIndices).IsSynchronized, "SelectedIndexCollectionTest_PropertiesTest#2");
- Assert.AreEqual (listview.SelectedIndices, ((ICollection)listview.SelectedIndices).SyncRoot, "SelectedIndexCollectionTest_PropertiesTest#3");
- Assert.AreEqual (true, ((IList)listview.SelectedIndices).IsFixedSize, "SelectedIndexCollectionTest_PropertiesTest#4");
- Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_PropertiesTest#5");
- }
- // Exceptions
- [Test, ExpectedException (typeof (NotSupportedException))]
- public void SelectedIndexCollectionTest_Add_ExceptionTest ()
- {
- ListView listview = new ListView ();
- ((IList)listview.SelectedIndices).Add (5);
- }
- [Test, ExpectedException (typeof (NotSupportedException))]
- public void SelectedIndexCollectionTest_Remove_ExceptionTest ()
- {
- ListView listview = new ListView ();
- ((IList)listview.SelectedIndices).Remove (5);
- }
- [Test, ExpectedException (typeof (NotSupportedException))]
- public void SelectedIndexCollectionTest_RemoveAt_ExceptionTest ()
- {
- ListView listview = new ListView ();
- ((IList)listview.SelectedIndices).RemoveAt (5);
- }
- /*
- SelectedItemCollection
- */
- [Test]
- public void SelectedItemCollectionTest_PropertiesTest ()
- {
- ListView listview = new ListView ();
- // Properties
- Assert.AreEqual (true, listview.SelectedItems.IsReadOnly, "SelectedItemCollectionTest_PropertiesTest#1");
- Assert.AreEqual (false, ((ICollection)listview.SelectedItems).IsSynchronized, "SelectedItemCollectionTest_PropertiesTest#2");
- Assert.AreEqual (listview.SelectedItems, ((ICollection)listview.SelectedItems).SyncRoot, "SelectedItemCollectionTest_PropertiesTest#3");
- Assert.AreEqual (true, ((IList)listview.SelectedItems).IsFixedSize, "SelectedItemCollectionTest_PropertiesTest#4");
- Assert.AreEqual (0, listview.SelectedItems.Count, "SelectedItemCollectionTest_PropertiesTest#5");
- }
- // Exceptions
- [Test, ExpectedException (typeof (NotSupportedException))]
- public void SelectedItemCollectionTest_PropertiesTest_Add_ExceptionTest ()
- {
- ListView listview = new ListView ();
- ((IList)listview.SelectedItems).Add (5);
- }
- [Test, ExpectedException (typeof (NotSupportedException))]
- public void SelectedItemCollectionTest_PropertiesTest_Remove_ExceptionTest ()
- {
- ListView listview = new ListView ();
- ((IList)listview.SelectedItems).Remove (5);
- }
- [Test, ExpectedException (typeof (NotSupportedException))]
- public void SelectedItemCollectionTest_PropertiesTest_RemoveAt_ExceptionTest ()
- {
- ListView listview = new ListView ();
- ((IList)listview.SelectedItems).RemoveAt (5);
- }
- }
- }
|