TreeViewImageIndexConverterTest.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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:
  8. //
  9. // The above copyright notice and this permission notice shall be
  10. // included in all copies or substantial portions of the Software.
  11. //
  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.
  19. //
  20. // Copyright (c) 2007 Novell, Inc.
  21. //
  22. #if NET_2_0
  23. using System;
  24. using System.ComponentModel;
  25. using System.Globalization;
  26. using System.Windows.Forms;
  27. using System.Windows.Forms.Layout;
  28. using NUnit.Framework;
  29. namespace MonoTests.System.Windows.Forms
  30. {
  31. [TestFixture]
  32. public class TreeViewImageIndexConverterTest : TestHelper
  33. {
  34. [Test]
  35. public void PropertyIncludeNoneAsStandardValue ()
  36. {
  37. PublicImageIndexConverter c = new PublicImageIndexConverter ();
  38. Assert.AreEqual (false, c.PublicIncludeNoneAsStandardValue, "A1");
  39. }
  40. private class PublicImageIndexConverter : TreeViewImageIndexConverter
  41. {
  42. public bool PublicIncludeNoneAsStandardValue { get { return base.IncludeNoneAsStandardValue; } }
  43. }
  44. [Test]
  45. public void GetStandardValues ()
  46. {
  47. TreeViewImageIndexConverter c = new TreeViewImageIndexConverter ();
  48. Assert.AreEqual (2, c.GetStandardValues (null).Count, "B1");
  49. Assert.AreEqual ("-1", c.GetStandardValues (null)[0].ToString (), "B2");
  50. Assert.AreEqual ("-2", c.GetStandardValues (null)[1].ToString (), "B3");
  51. }
  52. [Test]
  53. public void ConvertFrom ()
  54. {
  55. TreeViewImageIndexConverter iic = new TreeViewImageIndexConverter ();
  56. Assert.AreEqual (-1, iic.ConvertFrom (null, CultureInfo.CurrentCulture, "(default)"), "N1");
  57. Assert.AreEqual (-1, iic.ConvertFrom (null, CultureInfo.CurrentCulture, "(DEFAULT)"), "N1-1");
  58. Assert.AreEqual (-2, iic.ConvertFrom (null, CultureInfo.CurrentCulture, "(none)"), "N2");
  59. Assert.AreEqual (-2, iic.ConvertFrom (null, CultureInfo.CurrentCulture, "(nONE)"), "N2-1");
  60. Assert.AreEqual (0, iic.ConvertFrom (null, CultureInfo.CurrentCulture, "0"), "N3");
  61. Assert.AreEqual (6, iic.ConvertFrom (null, CultureInfo.CurrentCulture, "6"), "N4");
  62. Assert.AreEqual (-1, iic.ConvertFrom (null, CultureInfo.CurrentCulture, "-1"), "N5");
  63. Assert.AreEqual (-2, iic.ConvertFrom (null, CultureInfo.CurrentCulture, "-2"), "N6");
  64. }
  65. [Test]
  66. public void ConvertTo ()
  67. {
  68. TreeViewImageIndexConverter iic = new TreeViewImageIndexConverter ();
  69. Assert.AreEqual (string.Empty, iic.ConvertTo (null, null, string.Empty, typeof (string)), "N1");
  70. Assert.AreEqual (string.Empty, iic.ConvertTo (null, null, null, typeof (string)), "N2");
  71. Assert.AreEqual ("6", iic.ConvertTo (null, null, 6, typeof (string)), "N3");
  72. Assert.AreEqual ("(default)", iic.ConvertTo (null, null, -1, typeof (string)), "N4");
  73. Assert.AreEqual ("(none)", iic.ConvertTo (null, null, -2, typeof (string)), "N5");
  74. }
  75. }
  76. }
  77. #endif