Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LogRecordTest by using InvariantCulture. #1683

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion test/OpenTelemetry.Tests/Logs/LogRecordTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using OpenTelemetry.Logs;
using OpenTelemetry.Trace;
using Xunit;
using System.Globalization;

namespace OpenTelemetry.Tests.Logs
{
Expand Down Expand Up @@ -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;
Copy link
Member

@reyang reyang Jan 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a common need, consider making this a "using statement".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the only test that failed that way, at least with a German locale.

CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
try
{
Assert.Equal("[Name, truffle], [Price, 299.99]", state.ToString());
}
finally
{
CultureInfo.CurrentCulture = prevCulture;
}
}

[Fact]
Expand Down