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

Commit 67d2314

Browse files
committed
Change tests to run recommended net472 or net6.0 TFMs
1 parent 8df4588 commit 67d2314

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

tests/ServiceStack.Text.Tests/DictionaryTests.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public void Test_ServiceStack_Text_JsonSerializer_Array_Value_Deserializes_Corre
250250
}
251251

252252
[Test]
253-
public void deserizes_to_decimal_by_default()
253+
public void Deserializes_to_decimal_by_default()
254254
{
255255
JsConfig.TryToParsePrimitiveTypeValues = true;
256256

@@ -279,7 +279,7 @@ public NumericType(decimal min, decimal max, Type type)
279279
}
280280

281281
[Test]
282-
public void deserizes_signed_bytes_into_to_best_fit_numeric()
282+
public void Deserializes_signed_bytes_into_to_best_fit_numeric()
283283
{
284284
JsConfig.TryToParsePrimitiveTypeValues = true;
285285
JsConfig.TryToParseNumericType = true;
@@ -292,16 +292,18 @@ public void deserizes_signed_bytes_into_to_best_fit_numeric()
292292
Assert.That(deserializedDict["max"], Is.EqualTo(sbyte.MaxValue));
293293
}
294294

295+
#if NETFX
295296
[Test]
296-
public void deserizes_floats_into_to_best_fit_floating_point()
297+
public void Deserializes_floats_into_to_best_fit_floating_point()
297298
{
298299
JsConfig.TryToParsePrimitiveTypeValues = true;
299300
JsConfig.TryToParseNumericType = true;
300301
JsConfig.ParsePrimitiveFloatingPointTypes = ParseAsType.Single | ParseAsType.Double;
301302

302303
float floatValue = 1.1f;
303304
//TODO find a number that doesn't suck which throws in float.Parse() but not double.Parse()
304-
double doubleValue = double.MaxValue - Math.Pow(2, 1000);
305+
double Offset = Math.Pow(2, 1000);
306+
double doubleValue = double.MaxValue - Offset;
305307
var intValue = int.MaxValue;
306308
var longValue = long.MaxValue;
307309

@@ -311,17 +313,17 @@ public void deserizes_floats_into_to_best_fit_floating_point()
311313
var toFloatValue = float.Parse(floatValue.ToString());
312314
Assert.AreEqual(toFloatValue, floatValue, 1);
313315
var toDoubleValue = double.Parse(doubleValue.ToString());
314-
Assert.AreEqual(toDoubleValue, doubleValue, Math.Pow(2, 1000));
316+
Assert.AreEqual(toDoubleValue, doubleValue, Offset);
315317

316318
var json = "{{\"float\":{0},\"double\":{1},\"int\":{2},\"long\":{3}}}"
317319
.Fmt(CultureInfo.InvariantCulture, floatValue, doubleValue, intValue, longValue);
318320
var map = JsonSerializer.DeserializeFromString<IDictionary<string, object>>(json);
319321

320322
Assert.That(map["float"], Is.TypeOf<float>());
321323
Assert.That(map["float"], Is.EqualTo(floatValue));
322-
324+
323325
Assert.That(map["double"], Is.TypeOf<double>());
324-
Assert.AreEqual((double)map["double"], doubleValue, Math.Pow(2, 1000));
326+
Assert.AreEqual((double)map["double"], doubleValue, Offset);
325327

326328
Assert.That(map["int"], Is.TypeOf<int>());
327329
Assert.That(map["int"], Is.EqualTo(intValue));
@@ -331,9 +333,10 @@ public void deserizes_floats_into_to_best_fit_floating_point()
331333

332334
JsConfig.Reset();
333335
}
336+
#endif
334337

335338
[Test]
336-
public void deserizes_signed_types_into_to_best_fit_numeric()
339+
public void Deserializes_signed_types_into_to_best_fit_numeric()
337340
{
338341
var unsignedTypes = new[]
339342
{
@@ -365,7 +368,7 @@ public void deserizes_signed_types_into_to_best_fit_numeric()
365368
}
366369

367370
[Test]
368-
public void deserizes_unsigned_types_into_to_best_fit_numeric()
371+
public void Deserializes_unsigned_types_into_to_best_fit_numeric()
369372
{
370373
var unsignedTypes = new[]
371374
{

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
3+
<TargetFrameworks>net472;net6.0</TargetFrameworks>
44
<DebugType>portable</DebugType>
55
<AssemblyName>ServiceStack.Text.Tests</AssemblyName>
66
<OutputType>Library</OutputType>
@@ -16,7 +16,7 @@
1616
<LangVersion>latest</LangVersion>
1717
</PropertyGroup>
1818
<PropertyGroup>
19-
<DebugType Condition="'$(TargetFramework)' != '' AND '$(TargetFramework)' != 'netcoreapp2.1'">Full</DebugType>
19+
<DebugType Condition="'$(TargetFramework)' != '' AND '$(TargetFramework)' != 'net6.0'">Full</DebugType>
2020
</PropertyGroup>
2121
<ItemGroup>
2222
<ProjectReference Include="..\..\src\ServiceStack.Text\ServiceStack.Text.csproj" />
@@ -36,10 +36,10 @@
3636
<PackageReference Include="System.Memory" Version="4.5.4" />
3737
<PackageReference Include="ServiceStack" Version="5.*" />
3838
</ItemGroup>
39-
<PropertyGroup Condition=" '$(TargetFramework)' == 'net461' ">
40-
<DefineConstants>$(DefineConstants);NET45</DefineConstants>
39+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net472' ">
40+
<DefineConstants>$(DefineConstants);NETFX</DefineConstants>
4141
</PropertyGroup>
42-
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
42+
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
4343
<Reference Include="System.Configuration" />
4444
<Reference Include="System.Threading" />
4545
<Reference Include="System.Threading.Tasks" />
@@ -49,10 +49,10 @@
4949
<Reference Include="System.Web.Extensions" />
5050
<Reference Include="Microsoft.CSharp" />
5151
</ItemGroup>
52-
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
52+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
5353
<DefineConstants>$(DefineConstants);NETCORE;NETSTANDARD2_0</DefineConstants>
5454
</PropertyGroup>
55-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
55+
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
5656
<ProjectReference Include="..\..\src\ServiceStack.Memory\ServiceStack.Memory.csproj" />
5757
<PackageReference Include="System.Collections.Specialized" Version="4.*" />
5858
<PackageReference Include="System.Collections.NonGeneric" Version="4.*" />

0 commit comments

Comments
 (0)