Skip to content

Commit 86f6078

Browse files
committed
Avoid odd test failures
- XML serializers handle `DBNull` on some machines but not others - possible an underlying problem was fixed recently, in .NET Core SDK 2.0.3 - but, better to make builds work almost everywhere and wait for .NET Core SDK 2.1.x (where `DBNull` is seralizable)
1 parent a6291df commit 86f6078

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

test/System.Net.Http.Formatting.Test/Formatting/DataContractJsonMediaTypeFormatterTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_KnownTypes(Ty
157157
}
158158
}
159159

160+
#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0.
160161
// Test alternate null value
161162
[Fact]
162163
public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_DBNull()
@@ -187,6 +188,7 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_DBNullAsEmpty
187188
// Lower levels convert DBNull.Value to empty string on read
188189
Assert.Equal(String.Empty, readObj);
189190
}
191+
#endif
190192

191193
[Fact]
192194
public async Task UseDataContractJsonSerializer_Default()

test/System.Net.Http.Formatting.Test/Formatting/XmlMediaTypeFormatterTests.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,23 @@ public class XmlMediaTypeFormatterTests : MediaTypeFormatterTestBase<XmlMediaTyp
2323
// sample only; avoids types DataContractJsonSerializer fails to round trip (e.g. Guid, Uint16). May require
2424
// known types or similar (de)serializer configuration.
2525
public static readonly RefTypeTestData<object> BunchOfTypedObjectsTestData = new RefTypeTestData<object>(
26-
() => new List<object> { null, String.Empty, "This is a string", false, true, Double.MinValue,
27-
Double.MaxValue, Int32.MinValue, Int32.MaxValue, Int64.MinValue, Int64.MaxValue, DBNull.Value, });
26+
() => new List<object>
27+
{
28+
null,
29+
String.Empty,
30+
"This is a string",
31+
false,
32+
true,
33+
Double.MinValue,
34+
Double.MaxValue,
35+
Int32.MinValue,
36+
Int32.MaxValue,
37+
Int64.MinValue,
38+
Int64.MaxValue,
39+
#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0.
40+
DBNull.Value,
41+
#endif
42+
});
2843

2944
public static IEnumerable<TestData> BunchOfTypedObjectsTestDataCollection
3045
{

0 commit comments

Comments
 (0)