Skip to content

Commit 908f2fc

Browse files
authored
CSHARP-5285: Fix issues for tests due to locale (#1452)
1 parent e252ea6 commit 908f2fc

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/MongoDB.Driver.Tests/Core/Events/TraceSourceSdamEventSubscriberTests.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
using System;
1717
using System.Diagnostics;
18+
using System.Globalization;
1819
using System.IO;
1920
using System.Net;
2021
using FluentAssertions;
@@ -53,7 +54,7 @@ public void Handle_with_ClusterOpenedEvent_should_trace_event()
5354
const string logFileName = traceSourceName + "-log";
5455
var @event = new ClusterOpenedEvent(new ClusterId(), new ClusterSettings(), new TimeSpan(1));
5556
var expectedLogMessage =
56-
$"{TraceSourceEventHelper.Label(@event.ClusterId)}: opened in {@event.Duration.TotalMilliseconds}ms.";
57+
$"{TraceSourceEventHelper.Label(@event.ClusterId)}: opened in {@event.Duration.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)}ms.";
5758
var traceSource = CreateTraceSource(logFileName, logFileName);
5859
var subject = new TraceSourceSdamEventSubscriber(traceSource);
5960

@@ -86,7 +87,7 @@ public void Handle_with_ClusterClosedEvent_should_trace_event()
8687
const string logFileName = traceSourceName + "-log";
8788
var @event = new ClusterClosedEvent(new ClusterId(), new TimeSpan(1));
8889
var expectedLogMessage =
89-
$"{TraceSourceEventHelper.Label(@event.ClusterId)}: closed in {@event.Duration.TotalMilliseconds}ms.";
90+
$"{TraceSourceEventHelper.Label(@event.ClusterId)}: closed in {@event.Duration.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)}ms.";
9091
var traceSource = CreateTraceSource(logFileName, logFileName);
9192
var subject = new TraceSourceSdamEventSubscriber(traceSource);
9293

@@ -126,7 +127,7 @@ public void Handle_with_ClusterAddedServerEvent_should_trace_event()
126127
new TimeSpan(1));
127128
var expectedLogMessage =
128129
$"{TraceSourceEventHelper.Label(@event.ServerId.ClusterId)}: added server " +
129-
$"{TraceSourceEventHelper.Format(@event.ServerId)} in {@event.Duration.TotalMilliseconds}ms.";
130+
$"{TraceSourceEventHelper.Format(@event.ServerId)} in {@event.Duration.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)}ms.";
130131
var traceSource = CreateTraceSource(logFileName, logFileName);
131132
var subject = new TraceSourceSdamEventSubscriber(traceSource);
132133

@@ -167,7 +168,7 @@ public void Handle_with_ClusterRemovedServerEvent_should_trace_event()
167168
new TimeSpan(42));
168169
var expectedLogMessage =
169170
$"{TraceSourceEventHelper.Label(@event.ServerId.ClusterId)}: removed server " +
170-
$"{TraceSourceEventHelper.Format(@event.ServerId)} in {@event.Duration.TotalMilliseconds}ms. " +
171+
$"{TraceSourceEventHelper.Format(@event.ServerId)} in {@event.Duration.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)}ms. " +
171172
$"Reason: {@event.Reason}";
172173
var traceSource = CreateTraceSource(logFileName, logFileName);
173174
var subject = new TraceSourceSdamEventSubscriber(traceSource);
@@ -251,7 +252,7 @@ public void Handle_with_ServerOpenedEvent_should_trace_event()
251252
new ServerSettings(),
252253
new TimeSpan(42));
253254
var expectedLogMessage =
254-
$"{TraceSourceEventHelper.Label(@event.ServerId)}: opened in {@event.Duration.TotalMilliseconds}ms.";
255+
$"{TraceSourceEventHelper.Label(@event.ServerId)}: opened in {@event.Duration.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)}ms.";
255256
var traceSource = CreateTraceSource(logFileName, logFileName);
256257
var subject = new TraceSourceSdamEventSubscriber(traceSource);
257258

@@ -287,7 +288,7 @@ public void Handle_with_ServerClosedEvent_should_trace_event()
287288
new ServerId(new ClusterId(), new IPEndPoint(IPAddress.Parse("1.2.3.4"), 42)),
288289
new TimeSpan(42));
289290
var expectedLogMessage =
290-
$"{TraceSourceEventHelper.Label(@event.ServerId)}: closed in {@event.Duration.TotalMilliseconds}ms.";
291+
$"{TraceSourceEventHelper.Label(@event.ServerId)}: closed in {@event.Duration.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)}ms.";
291292
var traceSource = CreateTraceSource(logFileName, logFileName);
292293
var subject = new TraceSourceSdamEventSubscriber(traceSource);
293294

@@ -325,7 +326,7 @@ public void Handle_with_ServerHeartbeatSucceededEvent_should_trace_event()
325326
new TimeSpan(42),
326327
awaited: true);
327328
var expectedLogMessage =
328-
$"{TraceSourceEventHelper.Label(@event.ConnectionId)}: sent heartbeat in {@event.Duration.TotalMilliseconds}ms.";
329+
$"{TraceSourceEventHelper.Label(@event.ConnectionId)}: sent heartbeat in {@event.Duration.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)}ms.";
329330
var traceSource = CreateTraceSource(logFileName, logFileName);
330331
var subject = new TraceSourceSdamEventSubscriber(traceSource);
331332

0 commit comments

Comments
 (0)