mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-05 05:27:37 +08:00
6b0a8f45de
* fix:(module:datepicker): OnChange event in Docs project add(module:datepicker): generic OnPanelChange event add(module:datepicker): generic OnChange event fix(module:datepicker): DateTimeKind is not preserved add(module:datepicker): DateTimeOffset unit tests add(module:datepicker): add DateTimeOffset to range picker unit tests add(module:datepicker): refactor unit tests fix(module:datepicker): DateTime.Kind is not preserved feat(module: datepicker). Add DateTimeOffset, DateOnly, TimeOnly support * fix(module:datepicker): unit test fails * fix: moment helper test fails in VS Test Explorer in some cases See https://xunit.net/faq/theory-data-stability-in-vs * update the docs and demo --------- Co-authored-by: James Yeung <shunjiey@hotmail.com>
109 lines
7.8 KiB
C#
109 lines
7.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace AntDesign.Tests.DatePicker;
|
|
|
|
public static class RangePickerTestData
|
|
{
|
|
private const string DefaultDateFormat = "yyyy-MM-dd";
|
|
private const string DefaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss";
|
|
|
|
public static IEnumerable<object?[]> NullableData
|
|
{
|
|
get
|
|
{
|
|
yield return new object?[] { new[] { new DateTime?(new DateTime(2022, 6, 8, 20, 20, 0)), new DateTime(2022, 6, 8, 20, 20, 30) } };
|
|
yield return new object?[] { new[] { new DateTimeOffset?(new DateTimeOffset(2022, 6, 8, 20, 20, 0, TimeSpan.FromHours(5))), new DateTimeOffset?(new DateTimeOffset(2022, 6, 8, 20, 20, 30, TimeSpan.FromHours(5))) } };
|
|
|
|
#if NET6_0_OR_GREATER
|
|
yield return new object[] { new[] { new DateOnly?(DateOnly.FromDateTime(new DateTime(2022, 6, 8))), new DateOnly?(DateOnly.FromDateTime(new DateTime(2022, 6, 8))) } };
|
|
#endif
|
|
}
|
|
}
|
|
|
|
public static IEnumerable<object?[]> NullData
|
|
{
|
|
get
|
|
{
|
|
yield return new object?[] { new[] { new DateTime?(), new DateTime?() } };
|
|
yield return new object?[] { new[] { new DateTimeOffset?(), new DateTimeOffset?() } };
|
|
|
|
#if NET6_0_OR_GREATER
|
|
yield return new object?[] { new[] { new DateOnly?(), new DateOnly?() } };
|
|
#endif
|
|
}
|
|
}
|
|
|
|
public static IEnumerable<object?[]> SameDateRanges
|
|
{
|
|
get
|
|
{
|
|
yield return new object?[] { new[] { new DateTime?(new DateTime(2022, 6, 8, 20, 20, 0)), new DateTime(2022, 6, 8, 20, 20, 30) } };
|
|
yield return new object[] { new[] { new DateTime(2022, 6, 8, 20, 20, 0), new DateTime(2022, 6, 8, 20, 20, 30) } };
|
|
yield return new object?[] { new[] { new DateTimeOffset?(new DateTimeOffset(2022, 6, 8, 20, 20, 0, TimeSpan.FromHours(5))), new DateTimeOffset?(new DateTimeOffset(2022, 6, 8, 20, 20, 30, TimeSpan.FromHours(5))) } };
|
|
yield return new object[] { new[] { new DateTimeOffset(2022, 6, 8, 20, 20, 0, TimeSpan.FromHours(5)), new DateTimeOffset(2022, 6, 8, 20, 20, 30, TimeSpan.FromHours(5)) } };
|
|
}
|
|
}
|
|
|
|
public static IEnumerable<object?[]> NotSameDateRanges
|
|
{
|
|
get
|
|
{
|
|
yield return new object?[] { new[] { new DateTime?(new DateTime(2022, 6, 8, 20, 20, 0)), new DateTime?(new DateTime(2022, 6, 9, 10, 25, 15)) } };
|
|
yield return new object[] { new[] { new DateTime(2022, 6, 8, 20, 20, 0), new DateTime(2022, 6, 9, 10, 25, 15) } };
|
|
yield return new object?[] { new[] { new DateTimeOffset?(new DateTimeOffset(2022, 6, 8, 20, 20, 0, TimeSpan.FromHours(5))), new DateTimeOffset?(new DateTimeOffset(2022, 6, 9, 10, 25, 15, TimeSpan.FromHours(5))) } };
|
|
yield return new object[] { new[] { new DateTimeOffset(2022, 6, 8, 20, 20, 0, TimeSpan.FromHours(5)), new DateTimeOffset(2022, 6, 9, 10, 25, 15, TimeSpan.FromHours(5)) } };
|
|
}
|
|
}
|
|
|
|
public static IEnumerable<object?[]> InvalidKeyedInput
|
|
{
|
|
get
|
|
{
|
|
yield return new object?[] { 0, new[] { new DateTime?(new DateTime(2022, 6, 8, 20, 20, 0)), new DateTime(2022, 6, 8, 20, 20, 30) }, "2022-06-08 20:25:35", DefaultDateTimeFormat, true };
|
|
yield return new object?[] { 0, new[] { new DateTimeOffset?(new DateTimeOffset(2022, 6, 8, 20, 20, 0, TimeSpan.FromHours(5))), new DateTimeOffset?(new DateTimeOffset(2022, 6, 8, 20, 20, 30, TimeSpan.FromHours(5))) }, "2022-06-08 20:25:35", DefaultDateTimeFormat, true };
|
|
yield return new object?[] { 1, new[] { new DateTime?(new DateTime(2022, 6, 8, 20, 20, 0)), new DateTime(2022, 6, 8, 20, 20, 30) }, "2022-06-07 12:25:35", DefaultDateTimeFormat, true };
|
|
yield return new object?[] { 1, new[] { new DateTimeOffset?(new DateTimeOffset(2022, 6, 8, 20, 20, 0, TimeSpan.FromHours(5))), new DateTimeOffset?(new DateTimeOffset(2022, 6, 8, 20, 20, 30, TimeSpan.FromHours(5))) }, "2022-06-07 12:25:35", DefaultDateTimeFormat, true };
|
|
|
|
#if NET6_0_OR_GREATER
|
|
yield return new object[] { 0, new[] { new DateOnly?(DateOnly.FromDateTime(new DateTime(2022, 6, 8))), new DateOnly?(DateOnly.FromDateTime(new DateTime(2022, 6, 8))) }, "2022-06-09", DefaultDateFormat, false };
|
|
yield return new object[] { 1, new[] { new DateOnly?(DateOnly.FromDateTime(new DateTime(2022, 6, 8))), new DateOnly?(DateOnly.FromDateTime(new DateTime(2022, 6, 8))) }, "2022-06-07", DefaultDateFormat, false };
|
|
|
|
#endif
|
|
}
|
|
}
|
|
|
|
public static IEnumerable<object[]> ValidKeyedInput
|
|
{
|
|
get
|
|
{
|
|
yield return new object[] { "Enter", new[] { new DateTime(2020, 1, 1), new DateTime(2020, 1, 2) }, new[] { new DateTime(2020, 1, 1, 10, 30, 5), new DateTime(2020, 1, 2, 8, 20, 15) }, DefaultDateTimeFormat, true };
|
|
yield return new object[] { "Enter", new[] { new DateTime(2020, 1, 1), new DateTime(2020, 1, 2) }, new[] { new DateTime(2020, 1, 2), new DateTime(2020, 1, 5) }, DefaultDateFormat, false };
|
|
yield return new object[] { "Tab", new[] { new DateTime(2020, 1, 1), new DateTime(2020, 1, 2) }, new[] { new DateTime(2020, 1, 1, 10, 30, 5), new DateTime(2020, 1, 2, 8, 20, 15) }, DefaultDateTimeFormat, true };
|
|
yield return new object[] { "Tab", new[] { new DateTime(2020, 1, 1), new DateTime(2020, 1, 2) }, new[] { new DateTime(2020, 1, 2), new DateTime(2020, 1, 5) }, DefaultDateFormat, false };
|
|
|
|
yield return new object[] { "Enter", new[] { new DateTimeOffset(2020, 1, 1, 0, 0, 0, TimeSpan.FromHours(5)), new DateTimeOffset(2020, 1, 2, 0, 0, 0, TimeSpan.FromHours(5)) }, new[] { new DateTimeOffset(2020, 1, 1, 10, 30, 5, TimeSpan.FromHours(5)), new DateTimeOffset(2020, 1, 2, 8, 20, 15, TimeSpan.FromHours(5)) }, DefaultDateTimeFormat, true };
|
|
yield return new object[] { "Enter", new[] { new DateTimeOffset(2020, 1, 1, 0, 0, 0, TimeSpan.FromHours(5)), new DateTimeOffset(2020, 1, 2, 0, 0, 0, TimeSpan.FromHours(5)) }, new[] { new DateTimeOffset(2020, 1, 2, 0, 0, 0, TimeSpan.FromHours(5)), new DateTimeOffset(2020, 1, 5, 0, 0, 0, TimeSpan.FromHours(5)) }, DefaultDateFormat, false };
|
|
yield return new object[] { "Tab", new[] { new DateTimeOffset(2020, 1, 1, 0, 0, 0, TimeSpan.FromHours(5)), new DateTimeOffset(2020, 1, 2, 0, 0, 0, TimeSpan.FromHours(5)) }, new[] { new DateTimeOffset(2020, 1, 1, 10, 30, 5, TimeSpan.FromHours(5)), new DateTimeOffset(2020, 1, 2, 8, 20, 15, TimeSpan.FromHours(5)) }, DefaultDateTimeFormat, true };
|
|
yield return new object[] { "Tab", new[] { new DateTimeOffset(2020, 1, 1, 0, 0, 0, TimeSpan.FromHours(5)), new DateTimeOffset(2020, 1, 2, 0, 0, 0, TimeSpan.FromHours(5)) }, new[] { new DateTimeOffset(2020, 1, 2, 0, 0, 0, TimeSpan.FromHours(5)), new DateTimeOffset(2020, 1, 5, 0, 0, 0, TimeSpan.FromHours(5)) }, DefaultDateFormat, false };
|
|
|
|
|
|
#if NET6_0_OR_GREATER
|
|
yield return new object[] { "Enter", new[] { new DateOnly(2020, 1, 1), new DateOnly(2020, 1, 2) }, new[] { new DateOnly(2020, 2, 2), new DateOnly(2020, 2, 3) }, DefaultDateFormat, false };
|
|
yield return new object[] { "Tab", new[] { new DateOnly(2020, 1, 1), new DateOnly(2020, 1, 2) }, new[] { new DateOnly(2020, 1, 3), new DateOnly(2020, 1, 5) }, DefaultDateFormat, false };
|
|
#endif
|
|
}
|
|
}
|
|
|
|
public static IEnumerable<object[]> DateTimeOffsetKeyedInput
|
|
{
|
|
get
|
|
{
|
|
yield return new object[] { new[] { new DateTimeOffset(2020, 1, 1, 0, 0, 0, TimeSpan.FromHours(5)), new DateTimeOffset(2020, 1, 2, 0, 0, 0, TimeSpan.FromHours(5)) }, DefaultDateTimeFormat, true };
|
|
yield return new object[] { new[] { new DateTimeOffset(2022, 2, 1, 0, 0, 0, TimeSpan.Zero), new DateTimeOffset(2022, 2, 6, 0, 0, 0, TimeSpan.Zero) }, DefaultDateTimeFormat, true };
|
|
yield return new object[] { new[] { new DateTimeOffset(DateTime.Today), new DateTimeOffset(DateTime.Today.AddDays(1)) }, DefaultDateTimeFormat, true };
|
|
|
|
}
|
|
}
|
|
}
|