1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
23 // Jordi Mas i Hernandez <jordi@ximian.com>
28 using System.Windows.Forms;
30 using System.Reflection;
31 using NUnit.Framework;
33 namespace MonoTests.System.Windows.Forms
36 public class ListViewItemTest
39 public void ListViewItemConstructors ()
41 Font fnt = new Font ("Arial", 12);
42 ListViewItem item1 = new ListViewItem ("Hello folks");
43 Assert.AreEqual ("Hello folks", item1.Text, "Constructor#1");
45 ListViewItem item2 = new ListViewItem (new string [] {"Element1", "Element2"},
46 -1, Color.Blue, Color.Red, fnt);
48 Assert.AreEqual (item2.ForeColor, Color.Blue, "Constructor#2");
49 Assert.AreEqual (item2.BackColor, Color.Red, "Constructor#3");
51 Assert.AreEqual (2, item2.SubItems.Count,"Constructor#4");
52 Assert.AreEqual (Color.Blue, item2.SubItems[0].ForeColor,"Constructor#5");
53 Assert.AreEqual (Color.Red, item2.SubItems[0].BackColor, "Constructor#6");
54 Assert.AreEqual (fnt, item2.SubItems[0].Font, "Constructor#7");
55 Assert.AreEqual ("Element1", item2.SubItems[0].Text, "Constructor#8");
56 Assert.AreEqual ("Element2", item2.SubItems[1].Text, "Constructor#12");
60 public void ListViewItemDefaultValues ()
62 ListViewItem item = new ListViewItem ();
64 Assert.AreEqual (false, item.Focused, "DefaultValues#3");
65 Assert.AreEqual (false, item.Checked, "DefaultValues#4");
66 Assert.AreEqual (string.Empty, item.Text, "DefaultValues#5");
67 Assert.AreEqual (true, item.UseItemStyleForSubItems, "DefaultValues#6");
71 public void ListViewItemTestClone ()
73 ListViewItem item1 = new ListViewItem ("Hello");
74 item1.ForeColor = Color.Blue;
75 item1.BackColor = Color.Red;
76 item1.Font = new Font ("Arial", 14);
77 item1.SubItems.Add ("Element2");
79 ListViewItem item2 = (ListViewItem) item1.Clone ();
80 Assert.AreEqual (item2.ForeColor, Color.Blue, "Clone#1");
81 Assert.AreEqual (item2.BackColor, Color.Red, "Clone#2");
82 Assert.AreEqual (item2.Text, "Hello", "Clone#3");
83 Assert.AreEqual (item2.Font, item1.Font, "Clone#4");
84 Assert.AreEqual (2, item2.SubItems.Count, "Clone#5");
85 Assert.AreEqual (item2.SubItems[1].Text, "Element2", "Clone#6");