fix(grpc-data): H1 details hash formats every field invariant-culture (review 4)
This commit is contained in:
@@ -222,6 +222,34 @@ public sealed class PeerHistoryContinuationStoreTests
|
||||
store.Count.ShouldBe(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_details_hash_is_culture_invariant()
|
||||
{
|
||||
var variants = new HistoryReadVariant[]
|
||||
{
|
||||
new HistoryReadRawVariant(DateTime.UnixEpoch, DateTime.UnixEpoch.AddHours(1), 10, ReturnBounds: true),
|
||||
new HistoryReadProcessedVariant(DateTime.UnixEpoch, DateTime.UnixEpoch.AddHours(1), TimeSpan.FromTicks(-5),
|
||||
new Opc.Ua.AggregateConfiguration { PercentDataBad = 100, PercentDataGood = 100 }),
|
||||
new HistoryReadAtTimeVariant([DateTime.UnixEpoch, DateTime.UnixEpoch.AddSeconds(1)]),
|
||||
};
|
||||
var invariant = variants.Select(v => v.ComputeDetailsHash()).ToArray();
|
||||
|
||||
var odd = (System.Globalization.CultureInfo)System.Globalization.CultureInfo.InvariantCulture.Clone();
|
||||
odd.NumberFormat.NegativeSign = "~";
|
||||
odd.NumberFormat.NumberGroupSeparator = "'";
|
||||
odd.TextInfo.ListSeparator = "#";
|
||||
var previous = System.Globalization.CultureInfo.CurrentCulture;
|
||||
try
|
||||
{
|
||||
System.Globalization.CultureInfo.CurrentCulture = odd;
|
||||
variants.Select(v => v.ComputeDetailsHash()).ToArray().ShouldBe(invariant);
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.Globalization.CultureInfo.CurrentCulture = previous;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A monotonic test clock.</summary>
|
||||
private sealed class ManualClock : TimeProvider
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user