forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(calendar): Ensure Calendar & DateTimeFormatter are following App…
…licationLanguages state
- Loading branch information
1 parent
07bb5cc
commit 7dd5a7e
Showing
4 changed files
with
249 additions
and
97 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/Uno.UI.Tests/Windows_Globalization/Given_CalendarFormatter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System.Globalization; | ||
using System.Linq; | ||
using Windows.Globalization.DateTimeFormatting; | ||
using FluentAssertions; | ||
using FluentAssertions.Execution; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Uno.UI.Tests.Windows_Globalization | ||
{ | ||
[TestClass] | ||
public class Given_CalendarFormatter | ||
{ | ||
[TestMethod] | ||
[DataRow("day month year", "en-US", "{month.numeric}/{day.integer}/{year.full}")] | ||
[DataRow("day month year", "en-CA", "{year.full}-{month.numeric}-{day.integer(2)}")] | ||
[DataRow("day month year", "en-GB", "{day.integer(2)}/{month.numeric}/{year.full}")] | ||
[DataRow("day month year", "fr-CA", "{year.full}-{month.numeric}-{day.integer(2)}")] | ||
[DataRow("day month year", "fr-FR", "{day.integer(2)}/{month.numeric}/{year.full}")] | ||
[DataRow("day month year", "hu-HU", "{year.full}. {month.numeric}. {day.integer(2)}.")] | ||
public void When_UsingVariousLanguages(string format, string language, string expectedPattern) | ||
{ | ||
var sut = new DateTimeFormatter(format, new[] {language}); | ||
|
||
var firstPattern = sut.Patterns.First(); | ||
|
||
using var _ = new AssertionScope(); | ||
|
||
firstPattern.Should().Be(expectedPattern); | ||
firstPattern.Length.Should().Be(expectedPattern.Length); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow("day", "en-US|fr-CA|ru-RU", "{day.integer}|{day.integer}|{day.integer}")] | ||
[DataRow("day month year", "en-US|fr-CA", "{month.numeric}/{day.integer}/{year.full}|{year.full}-{month.numeric}-{day.integer(2)}")] | ||
[DataRow("month year", "en-US|fr-CA", "{month.full} {year.full}|{month.full}, {year.full}")] | ||
[DataRow("day month", "en-US|fr-CA", "{month.full} {day.integer}|{day.integer} {month.full}")] | ||
[DataRow("hour minute second", "en-US|fr-CA", "{hour}:{minute}:{second} {period.abbreviated}|{hour}:{minute}:{second}")] | ||
[DataRow("hour minute", "en-US|fr-CA", "{hour}:{minute} {period.abbreviated}|{hour}:{minute}")] | ||
public void When_UsingMultipleLanguages(string format, string languages, string expectedPatterns) | ||
{ | ||
var sut = new DateTimeFormatter(format, languages.Split('|')); | ||
|
||
sut.Patterns.Should().BeEquivalentTo(expectedPatterns.Split('|')); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.