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

Commit 0609b84

Browse files
committed
Add Can_customize_JSON_decimal test
1 parent cc5a2e9 commit 0609b84

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/ServiceStack.Text.Tests/JsonTests/CustomSerializerTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,24 @@ public void Can_serialize_custom_ints()
283283

284284
JsConfig.Reset();
285285
}
286+
287+
public class ModelDecimal
288+
{
289+
public decimal Decimal { get; set; }
290+
}
291+
292+
[Test]
293+
public void Can_customize_JSON_decimal()
294+
{
295+
JsConfig<decimal>.RawSerializeFn = d =>
296+
d.ToString(CultureInfo.CreateSpecificCulture("nl-NL"));
297+
298+
var dto = new ModelDecimal { Decimal = 1.33m };
299+
300+
Assert.That(dto.ToCsv(), Is.EqualTo("Decimal\r\n\"1,33\"\r\n"));
301+
Assert.That(dto.ToJsv(), Is.EqualTo("{Decimal:1,33}"));
302+
Assert.That(dto.ToJson(), Is.EqualTo("{\"Decimal\":1,33}"));
303+
}
286304
}
287305

288306
}

0 commit comments

Comments
 (0)