Skip to content

Commit

Permalink
Set the current culture to invariant culture for consistent numeric f…
Browse files Browse the repository at this point in the history
…ormatting across different environments. This is crucial because the output of string formatting for numbers can vary based on the machine's locale settings. Using the invariant culture ensures that the format "12,345.00" will be consistent regardless of the regional settings of the system on which this test runs.
  • Loading branch information
SergeyFM committed May 10, 2024
1 parent 0e898b0 commit 963ff88
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions OpenXMLTemplatesTest/Variables/VariableSourceTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Globalization;
using NUnit.Framework;
using OpenXMLTemplates.Variables;
using OpenXMLTemplates.Variables.Exceptions;
Expand Down Expand Up @@ -47,6 +48,9 @@ public void Format_Numeric_Fields_Value_Null()
[Test]
public void Format_Numeric_Fields()
{
// Set the current culture to invariant culture for consistent numeric formatting across different environments.
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;

var data = new Dictionary<string, object>
{
{ "prices", new List<string> { "123", "12345.0001" } }
Expand Down

0 comments on commit 963ff88

Please sign in to comment.