Skip to content

Commit d2b0262

Browse files
committed
Add nightly Humanizer test
1 parent c86b9f2 commit d2b0262

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<ItemGroup>
3737
<PackageReference Include="NodaTime" Version="2.4.5" />
3838
<PackageReference Include="MSBuild.StructuredLogger" Version="2.1.500" />
39+
<PackageReference Include="Humanizer" Version="*" />
3940
</ItemGroup>
4041

4142
<ItemGroup>

tests/MSBuildDeviceIntegration/Tests/DeploymentTest.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using NUnit.Framework.Interfaces;
1717
using Xamarin.ProjectTools;
1818
using System.Xml.XPath;
19+
using Humanizer;
1920

2021
namespace Xamarin.Android.Build.Tests
2122
{
@@ -41,13 +42,23 @@ public void BeforeDeploymentTests ()
4142

4243
proj = new XamarinFormsAndroidApplicationProject ();
4344
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
45+
proj.SetProperty ("_FastDeploymentDiagnosticLogging", "True");
46+
proj.PackageReferences.Add (new Package {
47+
Id = "Humanizer",
48+
Version = "*",
49+
});
4450
var mainPage = proj.Sources.First (x => x.Include () == "MainPage.xaml.cs");
45-
var source = mainPage.TextContent ().Replace ("InitializeComponent ();", @"InitializeComponent ();
51+
var source = mainPage.TextContent ()
52+
.Replace ("using System;", @"using System;
53+
using Humanizer;
54+
using System.Globalization;")
55+
.Replace ("InitializeComponent ();", @"InitializeComponent ();
4656
Console.WriteLine ($""TimeZoneInfoNative={Java.Util.TimeZone.Default.ID}"");
4757
Console.WriteLine ($""TimeZoneInfo={TimeZoneInfo.Local.DisplayName}"");
4858
Console.WriteLine ($""LocaleNative={Java.Util.Locale.Default.Language}-{Java.Util.Locale.Default.Country}"");
4959
Console.WriteLine ($""CurrentCulture={System.Globalization.CultureInfo.CurrentCulture.Name}"");
5060
Console.WriteLine ($""Strings.SomeString={Strings.SomeString}"");
61+
Console.WriteLine ($""Humanizer={DateTime.UtcNow.AddHours(-30).Humanize()}"");
5162
myLabel.Text = Strings.SomeString;
5263
");
5364
source = source.Replace ("Console.WriteLine (\"Button was Clicked!\");", @"Console.WriteLine (""Button was Clicked!"");
@@ -433,6 +444,18 @@ public void CheckLocalizationIsCorrect (string locale)
433444
Assert.IsTrue (WaitForActivityToStart (proj.PackageName, "MainActivity", logFile, timeout: 120), "Activity should have started");
434445
string line = "";
435446
string logCatFile = Path.Combine (Root, builder.ProjectDirectory, $"locale-logcat-{locale.Replace ("/", "-")}.log");
447+
var culture = new CultureInfo (locale);
448+
string expectedHumanized = DateTime.UtcNow.AddHours(-30).Humanize(culture: culture);
449+
Assert.IsTrue (MonitorAdbLogcat ((l) => {
450+
if (l.Contains ("Humanizer=")) {
451+
line = l;
452+
bool result = l.Contains ($"{expectedHumanized}");
453+
if (l.Contains ("Humanizer=") && !result)
454+
return false;
455+
return result;
456+
}
457+
return false;
458+
}, logCatFile, timeout:30), $"Humanizer should have been '{expectedHumanized}'. We found : {line}");
436459
ClickButton (proj.PackageName, "myXFButton", "CLICK ME");
437460
Assert.IsTrue (MonitorAdbLogcat ((l) => {
438461
if (l.Contains ("StringsClick=") || l.Contains ("Strings.SomeString=")) {

0 commit comments

Comments
 (0)