diff --git a/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Validation/InteropDecimalNumberClutureInfoTest.razor b/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Validation/InteropDecimalNumberClutureInfoTest.razor new file mode 100644 index 0000000..11806ea --- /dev/null +++ b/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Validation/InteropDecimalNumberClutureInfoTest.razor @@ -0,0 +1,78 @@ +@using System.Globalization +
+

Literal Decimal Number Cluture Info Validation

+
Interop Get
+
+ Status: + @if (TestStatus == "Passed") + { + @TestStatus + } + else if (TestStatus == "Failed") + { + @TestStatus + } + else + { + @TestStatus + } +
+ +
+ + + +@code { + public string TestStatus = "Pending"; + + private string testId => "InteropDecimalNumberClutureInfoTest"; + private decimal result; + private decimal expected = 0.0000000000000001334646852585m; + + private void HandleRunTest() + { + var clutureInfo = CultureInfo.CurrentCulture; + try + { + // Using de-DE because the decimal place is ',' for decimal/numbers. + CultureInfo.CurrentCulture = new CultureInfo( + "de-DE" + ); + + RunTest(); + ValidateTest(); + } + catch { } + finally + { + // Reset back to ClutureInfo before test changed it. + CultureInfo.CurrentCulture = clutureInfo; + } + } + + public void RunTest() + { + result = EventHorizonBlazorInterop.Get( + testId, + "value" + ); + } + + public void ValidateTest() + { + if (result == expected) + { + TestStatus = "Passed"; + } + else + { + TestStatus = "Failed"; + } + } +} diff --git a/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Validation/InteropValidationsPage.razor b/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Validation/InteropValidationsPage.razor index 701e0ab..0387fcf 100644 --- a/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Validation/InteropValidationsPage.razor +++ b/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Validation/InteropValidationsPage.razor @@ -3,6 +3,7 @@

Interop Validations

+ diff --git a/EventHorizon.Blazor.Interop/EventHorizonBlazorInterop.cs b/EventHorizon.Blazor.Interop/EventHorizonBlazorInterop.cs index 3d90258..640f315 100644 --- a/EventHorizon.Blazor.Interop/EventHorizonBlazorInterop.cs +++ b/EventHorizon.Blazor.Interop/EventHorizonBlazorInterop.cs @@ -1,6 +1,7 @@ namespace EventHorizon.Blazor.Interop { using System; + using System.Globalization; using System.Threading.Tasks; using Microsoft.JSInterop; using Microsoft.JSInterop.WebAssembly; @@ -209,9 +210,9 @@ params object[] args /// /// /// ( - /// entity => new Vector3(entity), - /// "document.createElement" + /// EventHorizonBlazorInterop.Get( + /// "document", + /// "nodeType" /// ); /// ]]> /// @@ -240,7 +241,8 @@ string prop } return (T)Convert.ChangeType( result, - Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T) + Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T), + CultureInfo.InvariantCulture ); }