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.
This commit is contained in:
Ryan Nowak 2019-07-19 12:51:54 -07:00 committed by Ryan Nowak
parent 3e10688d12
commit 4ac6a4ad35
1 changed files with 6 additions and 6 deletions

View File

@ -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")));