Author: jpobst Date: 2008-02-19 12:06:32 -0500 (Tue, 19 Feb 2008) New Revision: 96166
Added: trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/SelectionRangeTest.cs Modified: trunk/mcs/class/Managed.Windows.Forms/ChangeLog trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionRange.cs trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog Log: 2008-02-19 Jonathan Pobst <[EMAIL PROTECTED]> * SelectionRange.cs: Apply patch from Andy Hume to make constructor behavior more accurate. [Fixes bug #362117] 2008-02-19 Jonathan Pobst <[EMAIL PROTECTED]> * SelectionRangeTest.cs: Add tests from Andy Hume. 2008-02-19 Jonathan Pobst <[EMAIL PROTECTED]> * System.Windows.Forms_test.dll.sources: Added SelectionRangeTest.cs. Modified: trunk/mcs/class/Managed.Windows.Forms/ChangeLog =================================================================== --- trunk/mcs/class/Managed.Windows.Forms/ChangeLog 2008-02-19 17:03:53 UTC (rev 96165) +++ trunk/mcs/class/Managed.Windows.Forms/ChangeLog 2008-02-19 17:06:32 UTC (rev 96166) @@ -1,3 +1,7 @@ +2008-02-19 Jonathan Pobst <[EMAIL PROTECTED]> + + * System.Windows.Forms_test.dll.sources: Added SelectionRangeTest.cs. + 2008-02-06 Andreia Gaita <[EMAIL PROTECTED]> * build-csproj2k5: fixed mono.mozilla project guid Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog =================================================================== --- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog 2008-02-19 17:03:53 UTC (rev 96165) +++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog 2008-02-19 17:06:32 UTC (rev 96166) @@ -1,3 +1,8 @@ +2008-02-19 Jonathan Pobst <[EMAIL PROTECTED]> + + * SelectionRange.cs: Apply patch from Andy Hume to make + constructor behavior more accurate. [Fixes bug #362117] + 2008-02-19 Andreia Gaita <[EMAIL PROTECTED]> * Control.cs: Added a new flag is_disposing to track if the Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionRange.cs =================================================================== --- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionRange.cs 2008-02-19 17:03:53 UTC (rev 96165) +++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SelectionRange.cs 2008-02-19 17:06:32 UTC (rev 96166) @@ -40,6 +40,8 @@ // default parameterless construcor, use default values public SelectionRange () { + end = DateTime.MaxValue.Date; + start = DateTime.MinValue.Date; } // constructor that receives another range, copies it's Start and End values @@ -51,11 +53,11 @@ // constructor that receives two dates, uses the lower of the two as start public SelectionRange (DateTime lower, DateTime upper) { if (lower <= upper) { - end = upper; - start = lower; + end = upper.Date; + start = lower.Date; } else { - end = lower; - start = upper; + end = lower.Date; + start = upper.Date; } } Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources =================================================================== --- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources 2008-02-19 17:03:53 UTC (rev 96165) +++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources 2008-02-19 17:06:32 UTC (rev 96166) @@ -121,6 +121,7 @@ System.Windows.Forms/SaveFileDialogTest.cs System.Windows.Forms/ScrollableControlTest.cs System.Windows.Forms/ScrollBarTest.cs +System.Windows.Forms/SelectionRangeTest.cs System.Windows.Forms/SendKeysTest.cs System.Windows.Forms/SplitterTest.cs System.Windows.Forms/SplitContainerTests.cs Modified: trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog =================================================================== --- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog 2008-02-19 17:03:53 UTC (rev 96165) +++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog 2008-02-19 17:06:32 UTC (rev 96166) @@ -1,3 +1,7 @@ +2008-02-19 Jonathan Pobst <[EMAIL PROTECTED]> + + * SelectionRangeTest.cs: Add tests from Andy Hume. + 2008-02-19 Jonathan Pobst <[EMAIL PROTECTED]> * ComboBoxTest.cs: Use PreferredHeight in MethodScaleControl. Added: trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/SelectionRangeTest.cs =================================================================== --- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/SelectionRangeTest.cs 2008-02-19 17:03:53 UTC (rev 96165) +++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/SelectionRangeTest.cs 2008-02-19 17:06:32 UTC (rev 96166) @@ -0,0 +1,137 @@ +// +// SelectionRangeTest.cs +// +// 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) 2008 Andy Hume +// +// Authors: +// Andy Hume <[EMAIL PROTECTED]> + +using System; +using System.Windows.Forms; +using NUnit.Framework; + +namespace MonoTests.System.Windows.Forms +{ + [TestFixture] + public class SelectionRangeTest + { + + [Test] + public void DefaultConstructor () + { + SelectionRange sr = new SelectionRange (); + Assert.AreEqual (DateTime.MinValue, sr.Start, "Start"); + // "9999-12-31 00:00:00", note not 23:59:59. + Assert.AreEqual (DateTime.MaxValue.Date, sr.End, "End"); + + Assert.AreEqual (DateTimeKind.Unspecified, sr.Start.Kind, "Start Kind"); + Assert.AreEqual (DateTimeKind.Unspecified, sr.End.Kind, "End Kind"); + } + + [Test] + public void DefaultConstructor_ToString () + { + SelectionRange sr = new SelectionRange (); + // "9999-12-31 00:00:00", note not 23:59:59. + Assert.AreEqual (string.Format ("SelectionRange: Start: {0}, End: {1}", new DateTime (1, 1, 1).ToString (), new DateTime (9999, 12, 31).ToString ()), + sr.ToString (), "ToString"); + } + + [Test] + public void TwoDatesConstructor () + { + SelectionRange sr = new SelectionRange (new DateTime (2001, 1, 11), new DateTime (2008, 2, 17)); + Assert.AreEqual (new DateTime (2001, 1, 11), sr.Start, "Start"); + Assert.AreEqual (new DateTime (2008, 2, 17), sr.End, "End"); + } + + [Test] + public void TwoDatesConstructor_Backwards () // start > end + { + SelectionRange sr = new SelectionRange (new DateTime (2008, 2, 17), new DateTime (2001, 1, 11)); + Assert.AreEqual (new DateTime (2001, 1, 11), sr.Start, "Start"); + Assert.AreEqual (new DateTime (2008, 2, 17), sr.End, "End"); + } + + [Test] + public void TwoDatesConstructor_WithTime () + { + // Apparenly any time value is stripped, found while testing PropertyGrid. + SelectionRange sr = new SelectionRange (new DateTime (2001, 1, 11, 13, 14, 15), new DateTime (2008, 2, 17)); + Assert.AreEqual (new DateTime (2001, 1, 11), sr.Start, "Start"); + Assert.AreEqual (new DateTime (2008, 2, 17), sr.End, "End"); + } + + [Test] + public void TwoDatesConstructor_WithTime2 () + { + // Apparenly any time value is stripped, found while testing PropertyGrid. + SelectionRange sr = new SelectionRange (new DateTime (2001, 1, 11), new DateTime (2008, 2, 17, 1, 2, 3)); + Assert.AreEqual (new DateTime (2001, 1, 11), sr.Start, "Start"); + Assert.AreEqual (new DateTime (2008, 2, 17), sr.End, "End"); + + Assert.AreEqual (DateTimeKind.Unspecified, sr.Start.Kind, "Start Kind"); + Assert.AreEqual (DateTimeKind.Unspecified, sr.End.Kind, "End Kind"); + } + +#if NET_2_0 + [Test] + public void TwoDatesConstructor_WithTimeWithKindLocal () + { + // Apparenly any time value is stripped, found while testing PropertyGrid. + SelectionRange sr = new SelectionRange (new DateTime (2001, 1, 11, 13, 14, 15, DateTimeKind.Local), new DateTime (2008, 2, 17)); + Assert.AreEqual (new DateTime (2001, 1, 11), sr.Start, "Start"); + Assert.AreEqual (new DateTime (2008, 2, 17), sr.End, "End"); + // + Assert.AreEqual (DateTimeKind.Local, sr.Start.Kind, "Start Kind"); + Assert.AreEqual (DateTimeKind.Unspecified, sr.End.Kind, "End Kind"); + } + + [Test] + public void TwoDatesConstructor_WithTime2WithKindUtc () + { + // Apparenly any time value is stripped, found while testing PropertyGrid. + SelectionRange sr = new SelectionRange (new DateTime (2001, 1, 11), new DateTime (2008, 2, 17, 1, 2, 3, DateTimeKind.Utc)); + Assert.AreEqual (new DateTime (2001, 1, 11), sr.Start, "Start"); + Assert.AreEqual (new DateTime (2008, 2, 17), sr.End, "End"); + // + Assert.AreEqual (DateTimeKind.Unspecified, sr.Start.Kind, "Start Kind"); + Assert.AreEqual (DateTimeKind.Utc, sr.End.Kind, "End Kind"); + } + + [Test] + public void TwoDatesConstructor_WithTwoTimeWithTwoKinds () + { + // Apparenly any time value is stripped, found while testing PropertyGrid. + SelectionRange sr = new SelectionRange ( + new DateTime (2001, 1, 11, 1, 2, 3, DateTimeKind.Utc), + new DateTime (2008, 2, 17, 1, 2, 3, DateTimeKind.Local)); + Assert.AreEqual (new DateTime (2001, 1, 11), sr.Start, "Start"); + Assert.AreEqual (new DateTime (2008, 2, 17), sr.End, "End"); + // + Assert.AreEqual (DateTimeKind.Utc, sr.Start.Kind, "Start Kind"); + Assert.AreEqual (DateTimeKind.Local, sr.End.Kind, "End Kind"); + } +#endif + + } +} \ No newline at end of file Property changes on: trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/SelectionRangeTest.cs ___________________________________________________________________ Name: svn:eol-style + native _______________________________________________ Mono-patches maillist - Mono-patches@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-patches