Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit f737a94

Browse files
committed
Add test to test InvariantCulture serialization of numbers in different cultures
1 parent 10b9df0 commit f737a94

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/ServiceStack.Text.Tests/CultureInfoTests.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,43 @@ public void Serializes_long_double_without_E_notation()
8989
Assert.That(doubleStr, Is.EqualTo("1234567890123456"));
9090
}
9191

92+
public class NumberClass
93+
{
94+
public int IntValue { get; set; }
95+
public uint UIntValue { get; set; }
96+
public long LongValue { get; set; }
97+
public ulong ULongValue { get; set; }
98+
public float FloatValue { get; set; }
99+
public double DoubleValue { get; set; }
100+
public decimal DecimalValue { get; set; }
101+
102+
public static NumberClass Create(int i)
103+
{
104+
return new NumberClass
105+
{
106+
IntValue = i*1000,
107+
UIntValue = (uint) (i * 1000),
108+
LongValue = i * 1000,
109+
ULongValue = (ulong) (i * 1000),
110+
FloatValue = (float) (i * 1000 + .999),
111+
DoubleValue = i * 1000 + .999,
112+
DecimalValue = (decimal) (i * 1000 + .999),
113+
};
114+
}
115+
}
116+
117+
[Test]
118+
public void Does_use_invariant_culture_for_numbers()
119+
{
120+
var dto = NumberClass.Create(1);
121+
dto.ToJson().Print();
122+
dto.ToJsv().Print();
123+
dto.ToCsv().Print();
124+
125+
Assert.That(dto.ToJson(), Is.Not.StringContaining("1000,9"));
126+
Assert.That(dto.ToJsv(), Is.Not.StringContaining("1000,9"));
127+
Assert.That(dto.ToCsv(), Is.Not.StringContaining("1000,9"));
128+
}
129+
92130
}
93131
}

0 commit comments

Comments
 (0)