ListViewGroupTest.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // ListViewGroupTest.cs
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining
  5. // a copy of this software and associated documentation files (the
  6. // "Software"), to deal in the Software without restriction, including
  7. // without limitation the rights to use, copy, modify, merge, publish,
  8. // distribute, sublicense, and/or sell copies of the Software, and to
  9. // permit persons to whom the Software is furnished to do so, subject to
  10. // the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be
  13. // included in all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. //
  23. // Copyright (c) 2006 Daniel Nauck
  24. //
  25. // Author:
  26. // Daniel Nauck (dna(at)mono-project(dot)de)
  27. #if NET_2_0
  28. using System;
  29. using System.Windows.Forms;
  30. using System.Drawing;
  31. using System.Reflection;
  32. using System.Collections;
  33. using NUnit.Framework;
  34. namespace MonoTests.System.Windows.Forms
  35. {
  36. [TestFixture]
  37. public class ListViewGroupTest
  38. {
  39. ListView lv = null;
  40. [SetUp]
  41. public void SetUp()
  42. {
  43. lv = new ListView ();
  44. }
  45. [Test]
  46. public void DefaultProperties ()
  47. {
  48. //default ListView properties for groups
  49. Assert.AreEqual (true, lv.ShowGroups, "#A1");
  50. Assert.AreEqual (true, (lv.Groups != null), "#A2");
  51. Assert.AreEqual (0, lv.Groups.Count, "#A3");
  52. //default ListViewGroup properties
  53. ListViewGroup lg1 = new ListViewGroup ();
  54. Assert.AreEqual ("ListViewGroup", lg1.Header, "#A4");
  55. Assert.AreEqual (null, lg1.Name, "#A5");
  56. Assert.AreEqual (HorizontalAlignment.Left, lg1.HeaderAlignment, "#A6");
  57. Assert.AreEqual (0, lg1.Items.Count, "#A7");
  58. Assert.AreEqual (null, lg1.ListView, "#A8");
  59. Assert.AreEqual (null, lg1.Tag, "#A9");
  60. Assert.AreEqual (lg1.Header, lg1.ToString(), "#A10");
  61. }
  62. [Test]
  63. public void AddTest ()
  64. {
  65. ListViewGroup lg1 = new ListViewGroup ();
  66. lg1.Items.Add ("Item1");
  67. Assert.AreEqual (1, lg1.Items.Count, "#B1");
  68. Assert.AreEqual (null, lg1.Items[0].ListView, "#B2");
  69. lv.Groups.Add (lg1);
  70. Assert.AreEqual (null, lg1.Items[0].ListView, "#B3");
  71. Assert.AreEqual (false, lv.Items.Contains(lg1.Items[0]), "#B4");
  72. }
  73. [Test]
  74. public void RemoveTest ()
  75. {
  76. ListViewGroup lg1 = new ListViewGroup ();
  77. lg1.Items.Add ("Item1");
  78. lv.Groups.Add (lg1);
  79. lv.Groups.Remove (lg1);
  80. Assert.AreEqual (1, lg1.Items.Count, "#C1");
  81. Assert.AreEqual (0, lv.Items.Count, "#C2");
  82. Assert.AreEqual (false, lv.Items.Contains (lg1.Items[0]), "#C3");
  83. }
  84. }
  85. }
  86. #endif