Skip to content

Commit

Permalink
chore: Add runtime test for Time format
Browse files Browse the repository at this point in the history
  • Loading branch information
morning4coffe-dev committed Dec 17, 2024
1 parent 484fac7 commit 0e9220e
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,31 +104,31 @@ public void When_FormattingDateVariants_ShouldProduceExpectedFormats()
}
}

// TODO(DT): Currently is throwing unexpected results on WinUI as well, can't compare the expected results
/* [TestMethod]
[TestMethod]
public void When_FormattingTimeVariants_ShouldProduceExpectedFormats()
{
var expectedResults = new Dictionary<string, string>
{
{ "{hour.integer}:{minute.integer}", "14:30" },
{ "{hour.integer}:{minute.integer}:{second.integer}", "14:30:00" },
{ "{hour.integer}:{minute.integer}:{second.integer(2)}", "14:30:00" },
{ "{hour.integer}:{minute.integer} {period.abbreviated(2)}", "2:30 PM" },
{ "{hour.integer}:{minute.integer}:{second.integer} {period.abbreviated(2)}", "2:30:00 PM" },
{ "{minute.integer}:{second.integer}", "30:00" },
{ "{hour.integer}:{minute.integer}:{second.integer} {period.abbreviated(2)}", "2:30:0 PM" },
{ "{minute.integer}:{second.integer}", "30:0" },
{ "{second.integer}", "0" },
{ "{hour.integer}:{minute.integer}:{second.integer} UTC", "14:30:00 UTC" }
{ "{hour.integer}:{minute.integer}:{second.integer(2)} UTC", "14:30:00 UTC" }
};

foreach (var kvp in expectedResults)
{
var template = kvp.Key;
var expected = kvp.Value;

var formatter = new DateTimeFormatter(template);
var formattedTime = formatter.Format(_testDate);
var clock = template.Contains("period") ? ClockIdentifiers.TwelveHour : ClockIdentifiers.TwentyFourHour;

Check notice on line 126 in src/Uno.UI.RuntimeTests/Tests/Windows_Globalization/Given_DateTimeFormatter.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Uno.UI.RuntimeTests/Tests/Windows_Globalization/Given_DateTimeFormatter.cs#L126

Change this call to 'template.Contains' to an overload that accepts a 'StringComparison' as a parameter.

var formatter = new DateTimeFormatter(template, ["en-US"], "US", CalendarIdentifiers.Gregorian, clock);
var formattedTime = formatter.Format(new DateTime(2024, 6, 17, 14, 30, 0));

Assert.AreEqual(expected, formattedTime, $"Mismatch for template: {template}");
Console.WriteLine($"Template: {template}, Result: {formattedTime}");
}
}*/
}
}

0 comments on commit 0e9220e

Please sign in to comment.