From 4ac6a4ad35801001d6b971c06254bd3da078741c Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Fri, 19 Jul 2019 12:51:54 -0700 Subject: [PATCH] Fix second part of #12286 We used to be inconsistent between what we'd do when formatting a value based on whether or not you specified a format. This change brings us back into consistency. For a `default` DateTime/DateTimeOffset we will just call ToString on it. For a `default` nullable of these types we will return the empty string. --- src/Components/test/E2ETest/Tests/BindTest.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Components/test/E2ETest/Tests/BindTest.cs b/src/Components/test/E2ETest/Tests/BindTest.cs index 1f0dd5c496..0ca35690bb 100644 --- a/src/Components/test/E2ETest/Tests/BindTest.cs +++ b/src/Components/test/E2ETest/Tests/BindTest.cs @@ -759,7 +759,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests // For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side // Blazor have different formatting behaviour by default. - [Fact(Skip = "https://github.com/aspnet/AspNetCore/issues/12286")] + [Fact] public void CanBindTextboxDateTimeWithFormat() { var target = Browser.FindElement(By.Id("textbox-datetime-format")); @@ -770,11 +770,11 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests Assert.Equal(expected, DateTime.Parse(boundValue.Text)); Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"))); - // Clear textbox; value updates to emtpy because that's what we do for `default` when there's a format + // Clear textbox; value updates to the default target.Clear(); target.SendKeys("\t"); expected = default; - Browser.Equal(string.Empty, () => target.GetAttribute("value")); + Browser.Equal("01-01", () => target.GetAttribute("value")); Assert.Equal(expected, DateTime.Parse(boundValue.Text)); Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"))); @@ -818,7 +818,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests // For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side // Blazor have different formatting behaviour by default. - [Fact(Skip = "https://github.com/aspnet/AspNetCore/issues/12286")] + [Fact] public void CanBindTextboxDateTimeOffsetWithFormat() { var target = Browser.FindElement(By.Id("textbox-datetimeoffset-format")); @@ -829,10 +829,10 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests Assert.Equal(expected, DateTimeOffset.Parse(boundValue.Text)); Assert.Equal(expected, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"))); - // Clear textbox; value updates to emtpy because that's what we do for `default` when there's a format + // Clear textbox; value updates to the default target.Clear(); expected = default; - Browser.Equal(string.Empty, () => target.GetAttribute("value")); + Browser.Equal("01-01", () => target.GetAttribute("value")); Assert.Equal(expected, DateTimeOffset.Parse(boundValue.Text)); Assert.Equal(expected, DateTimeOffset.Parse(mirrorValue.GetAttribute("value")));