Skip to content

Commit eaec374

Browse files
authored
Workaround Xunit bug casting InlineData (#43570)
See xunit/xunit#2564 Workaround this issue by avoiding a cast between nullable numeric types.
1 parent 588ea16 commit eaec374

File tree

6 files changed

+32
-32
lines changed

6 files changed

+32
-32
lines changed

src/Middleware/StaticFiles/test/UnitTests/RangeHelperTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public void NormalizeRange_ReturnsNullWhenRangeEndEqualsZero()
3232
}
3333

3434
[Theory]
35-
[InlineData(0, null, 0, 2)]
36-
[InlineData(0, 0, 0, 0)]
35+
[InlineData(0L, null, 0L, 2L)]
36+
[InlineData(0L, 0L, 0L, 0L)]
3737
public void NormalizeRange_ReturnsNormalizedRange(long? start, long? end, long? normalizedStart, long? normalizedEnd)
3838
{
3939
// Arrange & Act

src/Servers/Kestrel/Core/test/KestrelServerLimitsTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public void MaxConnectionsDefault()
214214

215215
[Theory]
216216
[InlineData(null)]
217-
[InlineData(1u)]
217+
[InlineData(1L)]
218218
[InlineData(long.MaxValue)]
219219
public void MaxConnectionsValid(long? value)
220220
{
@@ -238,8 +238,8 @@ public void MaxConnectionsInvalid(long value)
238238

239239
[Theory]
240240
[InlineData(null)]
241-
[InlineData(0)]
242-
[InlineData(1)]
241+
[InlineData(0L)]
242+
[InlineData(1L)]
243243
[InlineData(long.MaxValue)]
244244
public void MaxUpgradedConnectionsValid(long? value)
245245
{
@@ -269,8 +269,8 @@ public void MaxRequestBodySizeDefault()
269269

270270
[Theory]
271271
[InlineData(null)]
272-
[InlineData(0)]
273-
[InlineData(1)]
272+
[InlineData(0L)]
273+
[InlineData(1L)]
274274
[InlineData(long.MaxValue)]
275275
public void MaxRequestBodySizeValid(long? value)
276276
{

src/Shared/ResultsTests/FileContentResultTestBase.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ public async Task WriteFileAsync_CopiesBuffer_ToOutputStream()
4242
}
4343

4444
[Theory]
45-
[InlineData(0, 4, "Hello", 5)]
46-
[InlineData(6, 10, "World", 5)]
47-
[InlineData(null, 5, "World", 5)]
48-
[InlineData(6, null, "World", 5)]
45+
[InlineData(0L, 4L, "Hello", 5L)]
46+
[InlineData(6L, 10L, "World", 5L)]
47+
[InlineData(null, 5L, "World", 5L)]
48+
[InlineData(6L, null, "World", 5L)]
4949
public async Task WriteFileAsync_PreconditionStateShouldProcess_WritesRangeRequested(
5050
long? start,
5151
long? end,

src/Shared/ResultsTests/FileStreamResultTestBase.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ protected abstract Task ExecuteAsync(
2222
bool enableRangeProcessing = false);
2323

2424
[Theory]
25-
[InlineData(0, 4, "Hello", 5)]
26-
[InlineData(6, 10, "World", 5)]
27-
[InlineData(null, 5, "World", 5)]
28-
[InlineData(6, null, "World", 5)]
25+
[InlineData(0L, 4L, "Hello", 5L)]
26+
[InlineData(6L, 10L, "World", 5L)]
27+
[InlineData(null, 5L, "World", 5L)]
28+
[InlineData(6L, null, "World", 5L)]
2929
public async Task WriteFileAsync_PreconditionStateShouldProcess_WritesRangeRequested(long? start, long? end, string expectedString, long contentLength)
3030
{
3131
// Arrange
@@ -326,7 +326,7 @@ public async Task WriteFileAsync_NotModified_RangeRequestedIgnored()
326326
}
327327

328328
[Theory]
329-
[InlineData(0)]
329+
[InlineData(0L)]
330330
[InlineData(null)]
331331
public async Task WriteFileAsync_RangeRequested_FileLengthZeroOrNull(long? fileLength)
332332
{

src/Shared/ResultsTests/PhysicalFileResultTestBase.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ protected abstract Task ExecuteAsync(
2828
bool enableRangeProcessing = false);
2929

3030
[Theory]
31-
[InlineData(0, 3, 4)]
32-
[InlineData(8, 13, 6)]
33-
[InlineData(null, 5, 5)]
34-
[InlineData(8, null, 26)]
31+
[InlineData(0L, 3L, 4L)]
32+
[InlineData(8L, 13L, 6L)]
33+
[InlineData(null, 5L, 5L)]
34+
[InlineData(8L, null, 26L)]
3535
public async Task WriteFileAsync_WritesRangeRequested(long? start, long? end, long contentLength)
3636
{
3737
// Arrange
@@ -284,10 +284,10 @@ public async Task ExecuteResultAsync_CallsSendFileAsync_IfIHttpSendFilePresent()
284284
}
285285

286286
[Theory]
287-
[InlineData(0, 3, 4)]
288-
[InlineData(8, 13, 6)]
289-
[InlineData(null, 3, 3)]
290-
[InlineData(8, null, 26)]
287+
[InlineData(0L, 3L, 4L)]
288+
[InlineData(8L, 13L, 6L)]
289+
[InlineData(null, 3L, 3L)]
290+
[InlineData(8L, null, 26L)]
291291
public async Task ExecuteResultAsync_CallsSendFileAsyncWithRequestedRange_IfIHttpSendFilePresent(long? start, long? end, long contentLength)
292292
{
293293
// Arrange

src/Shared/ResultsTests/VirtualFileResultTestBase.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ protected abstract Task ExecuteAsync(
3131
bool enableRangeProcessing = false);
3232

3333
[Theory]
34-
[InlineData(0, 3, 4)]
35-
[InlineData(8, 13, 6)]
36-
[InlineData(null, 4, 4)]
37-
[InlineData(8, null, 25)]
34+
[InlineData(0L, 3L, 4L)]
35+
[InlineData(8L, 13L, 6L)]
36+
[InlineData(null, 4L, 4L)]
37+
[InlineData(8L, null, 25L)]
3838
public async Task WriteFileAsync_WritesRangeRequested(
3939
long? start,
4040
long? end,
@@ -314,10 +314,10 @@ public async Task WriteFileAsync_RangeRequested_NotModified()
314314
}
315315

316316
[Theory]
317-
[InlineData(0, 3, 4)]
318-
[InlineData(8, 13, 6)]
319-
[InlineData(null, 3, 3)]
320-
[InlineData(8, null, 25)]
317+
[InlineData(0L, 3L, 4L)]
318+
[InlineData(8L, 13L, 6L)]
319+
[InlineData(null, 3L, 3L)]
320+
[InlineData(8L, null, 25L)]
321321
public async Task ExecuteResultAsync_CallsSendFileAsyncWithRequestedRange_IfIHttpSendFilePresent(long? start, long? end, long contentLength)
322322
{
323323
// Arrange

0 commit comments

Comments
 (0)