From 3bb0445aa4810e09d16af4e060fe19547b0080cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Mon, 11 Jan 2021 18:44:08 +0100 Subject: [PATCH] Fix LogRecordTest by using InvariantCulture. (#1683) * Fix LogRecordTest by using InvariantCulture. The test would fail if the current locale used something other than a dot as the decimal separator (e.g. comma). * dotnet-format --- test/OpenTelemetry.Tests/Logs/LogRecordTest.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/OpenTelemetry.Tests/Logs/LogRecordTest.cs b/test/OpenTelemetry.Tests/Logs/LogRecordTest.cs index 412b0022470..3d890ec849a 100644 --- a/test/OpenTelemetry.Tests/Logs/LogRecordTest.cs +++ b/test/OpenTelemetry.Tests/Logs/LogRecordTest.cs @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.Linq; using Microsoft.Extensions.Logging; using OpenTelemetry.Exporter; @@ -213,7 +214,16 @@ public void CheckStateForStrucutredLogWithGeneralType() Assert.Contains(state, item => item.Key == "{OriginalFormat}"); Assert.Equal("{food}", state.First(item => item.Key == "{OriginalFormat}").Value); - Assert.Equal("[Name, truffle], [Price, 299.99]", state.ToString()); + var prevCulture = CultureInfo.CurrentCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; + try + { + Assert.Equal("[Name, truffle], [Price, 299.99]", state.ToString()); + } + finally + { + CultureInfo.CurrentCulture = prevCulture; + } } [Fact]