DateTimePickerTest.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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) 2006 Novell, Inc.
  21. //
  22. // Authors:
  23. // Rolf Bjarne Kvinge [email protected]
  24. using System;
  25. using System.ComponentModel;
  26. using System.Drawing;
  27. using System.Reflection;
  28. using System.Windows.Forms;
  29. using NUnit.Framework;
  30. namespace MonoTests.System.Windows.Forms {
  31. [TestFixture]
  32. public class DateTimePickerTest {
  33. [Test]
  34. public void DefaultPropertiesTest ()
  35. {
  36. DateTimePicker dt = new DateTimePicker ();
  37. Assert.AreEqual ("Window", dt.BackColor.Name, "B1");
  38. Assert.AreSame (null, dt.BackgroundImage, "B2");
  39. #if NET_2_0
  40. Assert.AreEqual (ImageLayout.Tile, dt.BackgroundImageLayout, "B3");
  41. #endif
  42. //Assert.AreSame (null, dt.CalendarFont, "C1");
  43. Assert.AreEqual ("ControlText", dt.CalendarForeColor.Name, "C2");
  44. Assert.AreEqual ("Window", dt.CalendarMonthBackground.Name, "C3");
  45. Assert.AreEqual ("ActiveCaption", dt.CalendarTitleBackColor.Name, "C4");
  46. Assert.AreEqual ("ActiveCaptionText", dt.CalendarTitleForeColor.Name, "C5");
  47. Assert.AreEqual ("GrayText", dt.CalendarTrailingForeColor.Name, "C6");
  48. Assert.AreEqual (true, dt.Checked, "C7");
  49. Assert.AreEqual (null, dt.CustomFormat, "C8");
  50. Assert.AreEqual (LeftRightAlignment.Left, dt.DropDownAlign, "D1");
  51. Assert.AreEqual ("WindowText", dt.ForeColor.Name, "F1");
  52. Assert.AreEqual (DateTimePickerFormat.Long, dt.Format, "F2");
  53. Assert.AreEqual (new DateTime (9998, 12, 31, 0, 0, 0), dt.MaxDate, "M1");
  54. Assert.AreEqual (new DateTime (9998, 12, 31, 0, 0, 0), DateTimePicker.MaxDateTime, "M2");
  55. Assert.AreEqual (new DateTime (1753, 1, 1), dt.MinDate, "M3");
  56. Assert.AreEqual (new DateTime (1753, 1, 1), DateTimePicker.MinDateTime, "M4");
  57. #if NET_2_0
  58. Assert.AreEqual (new DateTime (9998, 12, 31, 0, 0, 0), DateTimePicker.MaximumDateTime, "M5");
  59. Assert.AreEqual (new DateTime (1753, 1, 1), DateTimePicker.MinimumDateTime, "M6");
  60. #endif
  61. #if NET_2_0
  62. Assert.AreEqual (new Padding (0, 0, 0, 0), dt.Padding, "P1");
  63. #endif
  64. // PreferredHeight is Font dependent.
  65. #if NET_2_0
  66. Assert.AreEqual (false, dt.RightToLeftLayout, "R1");
  67. #endif
  68. Assert.AreEqual (false, dt.ShowCheckBox, "S1");
  69. Assert.AreEqual (false, dt.ShowUpDown, "S2");
  70. Assert.AreEqual ("", dt.Text, "T1");
  71. Assert.AreEqual (DateTime.Today, dt.Value.Date, "V1");
  72. }
  73. [Test]
  74. public void TextTest ()
  75. {
  76. DateTimePicker dt = new DateTimePicker ();
  77. DateTime tomorrow = DateTime.Today.AddDays (1);
  78. dt.Value = tomorrow;
  79. Assert.AreEqual ("", dt.Text, "#1");
  80. dt.CreateControl ();
  81. Assert.AreEqual (tomorrow.ToLongDateString (), dt.Text, "#2");
  82. }
  83. }
  84. }