Skip to content

Commit a18ca4a

Browse files
committed
Isolate MediaTypeFormatterTests.MaxCollectionKeySize_RoundTrips
- in recent CI run, another test failed because `MediaTypeFormatter.MaxHttpCollectionKeys == 1` temporarily - also left `MediaTypeFormatter.MaxHttpCollectionKeys == 125` which could affect later tests
1 parent 7dad200 commit a18ca4a

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
namespace System.Net.Http.Formatting
1818
{
19+
[Xunit.Collection("MediaTypeFormatterTests")] // Isolate MaxCollectionKeySize_RoundTrips.
20+
[Xunit.CollectionDefinition("MediaTypeFormatterTests", DisableParallelization = true)]
1921
public class MediaTypeFormatterTests
2022
{
2123
private const string TestMediaType = "text/test";
@@ -79,15 +81,23 @@ void CopyConstructor()
7981
[Fact]
8082
public void MaxCollectionKeySize_RoundTrips()
8183
{
82-
Assert.Reflection.IntegerProperty<MediaTypeFormatter, int>(
83-
null,
84-
c => MediaTypeFormatter.MaxHttpCollectionKeys,
85-
expectedDefaultValue: PlatformInfo.Platform == Platform.Net40 ? 1000 : Int32.MaxValue,
86-
minLegalValue: 1,
87-
illegalLowerValue: 0,
88-
maxLegalValue: null,
89-
illegalUpperValue: null,
90-
roundTripTestValue: 125);
84+
var defaultMaxKeys = MediaTypeFormatter.MaxHttpCollectionKeys;
85+
try
86+
{
87+
Assert.Reflection.IntegerProperty<MediaTypeFormatter, int>(
88+
null,
89+
c => MediaTypeFormatter.MaxHttpCollectionKeys,
90+
expectedDefaultValue: PlatformInfo.Platform == Platform.Net40 ? 1000 : Int32.MaxValue,
91+
minLegalValue: 1,
92+
illegalLowerValue: 0,
93+
maxLegalValue: null,
94+
illegalUpperValue: null,
95+
roundTripTestValue: 125);
96+
}
97+
finally
98+
{
99+
MediaTypeFormatter.MaxHttpCollectionKeys = defaultMaxKeys;
100+
}
91101
}
92102

93103
[Fact]

0 commit comments

Comments
 (0)