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

Commit 26b1d81

Browse files
committed
Tests for the IFormattable usage
This commit is separated from the implementation as it is unclear whether the Rect class is available in all environments
1 parent fbdc355 commit 26b1d81

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tests/ServiceStack.Text.Net40.Tests/ServiceStack.Text.Net40.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<Reference Include="Microsoft.CSharp" />
6969
<Reference Include="System.Data" />
7070
<Reference Include="System.Xml" />
71+
<Reference Include="WindowsBase" />
7172
</ItemGroup>
7273
<ItemGroup>
7374
<Compile Include="..\ServiceStack.Text.Tests\AdhocModelTests.cs">

tests/ServiceStack.Text.Tests/StructTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Drawing;
4+
using System.Globalization;
35
using System.Linq;
6+
using System.Threading;
7+
using System.Windows;
48
using NUnit.Framework;
59
using ServiceStack.Text.Common;
610

@@ -253,6 +257,23 @@ public void StaticParseMethod_will_not_throw_on_unstandard_usage()
253257
Assert.DoesNotThrow(() => ret = StaticParseMethod<DangerousText2>.Parse);
254258
Assert.IsNull(ret);
255259
}
260+
261+
[Test]
262+
[TestCase("en")]
263+
[TestCase("en-US")]
264+
[TestCase("de-CH")]
265+
[TestCase("de")]
266+
public void test_rect_different_cultures(string culture)
267+
{
268+
var currentCulture = CultureInfo.GetCultureInfo(culture);
269+
Thread.CurrentThread.CurrentCulture = currentCulture;
270+
Thread.CurrentThread.CurrentUICulture = currentCulture;
271+
var s = new JsonSerializer<Rect>();
272+
var r = new Rect(23, 34, 1024, 768);
273+
var interim = s.SerializeToString(r);
274+
var r2 = s.DeserializeFromString(interim);
275+
Assert.AreEqual(r, r2);
276+
}
256277
}
257278

258279
public struct UserStruct

0 commit comments

Comments
 (0)