Skip to content

Commit

Permalink
Port test changes from 1dd43ce
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Jul 22, 2022
1 parent 211aa27 commit 7eba502
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 41 deletions.
5 changes: 3 additions & 2 deletions test/test.xunit.assert/Asserts/CollectionAssertsTests.cs
Expand Up @@ -547,9 +547,10 @@ public static void ItemNotFound_Throws()
public class Distinct
{
[Fact]
public static void GuardClause()
public static void GuardClauses()
{
Assert.Throws<ArgumentNullException>("collection", () => Assert.Distinct<int>(null!));
Assert.Throws<ArgumentNullException>("comparer", () => Assert.Distinct(new object[0], null!));
}

[Fact]
Expand Down Expand Up @@ -586,11 +587,11 @@ public static void TwoNulls()
);
}


[Fact]
public static void CaseSensitiveStrings()
{
var list = new string[] { "a", "b", "A" };

Assert.Distinct(list);
Assert.Distinct(list, StringComparer.Ordinal);
}
Expand Down
60 changes: 30 additions & 30 deletions test/test.xunit.assert/Asserts/ExceptionAssertsTests.cs
Expand Up @@ -152,7 +152,7 @@ public static void GotExpectedException()
public class ThrowsAsync_Generic
{
[Fact]
public static async void ExpectExceptionButCodeDoesNotThrow()
public static async Task ExpectExceptionButCodeDoesNotThrow()
{
try
{
Expand All @@ -165,7 +165,7 @@ public static async void ExpectExceptionButCodeDoesNotThrow()
}

[Fact]
public static async void ExpectExceptionButCodeThrowsDerivedException()
public static async Task ExpectExceptionButCodeThrowsDerivedException()
{
try
{
Expand All @@ -180,7 +180,7 @@ public static async void ExpectExceptionButCodeThrowsDerivedException()
}

[Fact]
public static async void UnexpectedExceptionCapturedAsyncAsInnerException()
public static async Task UnexpectedExceptionCapturedAsyncAsInnerException()
{
try
{
Expand All @@ -195,7 +195,7 @@ public static async void UnexpectedExceptionCapturedAsyncAsInnerException()
}

[Fact]
public static async void GotExpectedException()
public static async Task GotExpectedException()
{
static Task testCode() => Task.Run(() => throw new ArgumentException());

Expand All @@ -209,7 +209,7 @@ public static async void GotExpectedException()
public class ThrowsAsync_Generic_ValueTask
{
[Fact]
public static async ValueTask ExpectExceptionButCodeDoesNotThrow()
public static async Task ExpectExceptionButCodeDoesNotThrow()
{
try
{
Expand All @@ -222,7 +222,7 @@ public static async ValueTask ExpectExceptionButCodeDoesNotThrow()
}

[Fact]
public static async ValueTask ExpectExceptionButCodeThrowsDerivedException()
public static async Task ExpectExceptionButCodeThrowsDerivedException()
{
try
{
Expand All @@ -237,7 +237,7 @@ public static async ValueTask ExpectExceptionButCodeThrowsDerivedException()
}

[Fact]
public static async ValueTask UnexpectedExceptionCapturedAsyncAsInnerException()
public static async Task UnexpectedExceptionCapturedAsyncAsInnerException()
{
try
{
Expand All @@ -252,7 +252,7 @@ public static async ValueTask UnexpectedExceptionCapturedAsyncAsInnerException()
}

[Fact]
public static async ValueTask GotExpectedException()
public static async Task GotExpectedException()
{
static ValueTask testCode() => throw new ArgumentException();

Expand Down Expand Up @@ -384,7 +384,7 @@ public static void GotDerivedException()
public class ThrowsAnyAsync_Generic
{
[Fact]
public static async void ExpectExceptionButCodeDoesNotThrow()
public static async Task ExpectExceptionButCodeDoesNotThrow()
{
try
{
Expand All @@ -397,7 +397,7 @@ public static async void ExpectExceptionButCodeDoesNotThrow()
}

[Fact]
public static async void GotExpectedException()
public static async Task GotExpectedException()
{
static Task testCode() => Task.Run(() => throw new ArgumentException());

Expand All @@ -407,7 +407,7 @@ public static async void GotExpectedException()
}

[Fact]
public static async void GotDerivedException()
public static async Task GotDerivedException()
{
try
{
Expand All @@ -426,7 +426,7 @@ public static async void GotDerivedException()
public class ThrowsAnyAsync_Generic_ValueTask
{
[Fact]
public static async ValueTask ExpectExceptionButCodeDoesNotThrow()
public static async Task ExpectExceptionButCodeDoesNotThrow()
{
try
{
Expand All @@ -439,7 +439,7 @@ public static async ValueTask ExpectExceptionButCodeDoesNotThrow()
}

[Fact]
public static async ValueTask GotExpectedException()
public static async Task GotExpectedException()
{
static ValueTask testCode() => throw new ArgumentException();

Expand All @@ -449,7 +449,7 @@ public static async ValueTask GotExpectedException()
}

[Fact]
public static async ValueTask GotDerivedException()
public static async Task GotDerivedException()
{
try
{
Expand Down Expand Up @@ -561,7 +561,7 @@ public static void GotExpectedException()
public class ThrowsAsync_NonGeneric
{
[Fact]
public static async void ExpectExceptionButCodeDoesNotThrow()
public static async Task ExpectExceptionButCodeDoesNotThrow()
{
try
{
Expand All @@ -576,7 +576,7 @@ public static async void ExpectExceptionButCodeDoesNotThrow()
}

[Fact]
public static async void ExpectExceptionButCodeThrowsDerivedException()
public static async Task ExpectExceptionButCodeThrowsDerivedException()
{
try
{
Expand All @@ -591,7 +591,7 @@ public static async void ExpectExceptionButCodeThrowsDerivedException()
}

[Fact]
public static async void GotExpectedException()
public static async Task GotExpectedException()
{
static Task testCode() => Task.Run(() => throw new ArgumentException());

Expand All @@ -606,7 +606,7 @@ public static async void GotExpectedException()
public class ThrowsAsync_NonGeneric_ValueTask
{
[Fact]
public static async ValueTask ExpectExceptionButCodeDoesNotThrow()
public static async Task ExpectExceptionButCodeDoesNotThrow()
{
try
{
Expand All @@ -621,7 +621,7 @@ public static async ValueTask ExpectExceptionButCodeDoesNotThrow()
}

[Fact]
public static async ValueTask ExpectExceptionButCodeThrowsDerivedException()
public static async Task ExpectExceptionButCodeThrowsDerivedException()
{
try
{
Expand All @@ -636,7 +636,7 @@ public static async ValueTask ExpectExceptionButCodeThrowsDerivedException()
}

[Fact]
public static async ValueTask GotExpectedException()
public static async Task GotExpectedException()
{
static ValueTask testCode() => throw new ArgumentException();

Expand Down Expand Up @@ -733,7 +733,7 @@ public static void GuardClause()
public class ThrowsArgumentAsync
{
[Fact]
public static async void ExpectExceptionButCodeDoesNotThrow()
public static async Task ExpectExceptionButCodeDoesNotThrow()
{
static Task testCode() => Task.Run(() => { });

Expand All @@ -744,7 +744,7 @@ public static async void ExpectExceptionButCodeDoesNotThrow()
}

[Fact]
public static async void ExpectExceptionButCodeThrowsDerivedException()
public static async Task ExpectExceptionButCodeThrowsDerivedException()
{
static Task testCode() => Task.Run(() => throw new InvalidOperationException());

Expand All @@ -760,7 +760,7 @@ public static async void ExpectExceptionButCodeThrowsDerivedException()
}

[Fact]
public static async void StackTraceForThrowsIsOriginalThrowNotAssertThrows()
public static async Task StackTraceForThrowsIsOriginalThrowNotAssertThrows()
{
static Task testCode() => Task.Run(() => ThrowingMethod());

Expand All @@ -778,15 +778,15 @@ static void ThrowingMethod()
}

[Fact]
public static async void GotExpectedException()
public static async Task GotExpectedException()
{
var ex = await Assert.ThrowsAsync<ArgumentException>("paramName", () => Task.Run(() => { throw new ArgumentException("message", "paramName"); }));

Assert.NotNull(ex);
}

[Fact]
public static async void MismatchedParameterName()
public static async Task MismatchedParameterName()
{
static Task testCode() => Task.Run(() => { throw new ArgumentException("message", "paramName2"); });

Expand All @@ -802,7 +802,7 @@ public static async void MismatchedParameterName()
public class ThrowsArgumentAsync_ValueTask
{
[Fact]
public static async ValueTask ExpectExceptionButCodeDoesNotThrow()
public static async Task ExpectExceptionButCodeDoesNotThrow()
{
static ValueTask testCode() => default;

Expand All @@ -813,7 +813,7 @@ public static async ValueTask ExpectExceptionButCodeDoesNotThrow()
}

[Fact]
public static async ValueTask ExpectExceptionButCodeThrowsDerivedException()
public static async Task ExpectExceptionButCodeThrowsDerivedException()
{
static ValueTask testCode() => throw new InvalidOperationException();

Expand All @@ -829,7 +829,7 @@ public static async ValueTask ExpectExceptionButCodeThrowsDerivedException()
}

[Fact]
public static async ValueTask StackTraceForThrowsIsOriginalThrowNotAssertThrows()
public static async Task StackTraceForThrowsIsOriginalThrowNotAssertThrows()
{
static ValueTask testCode() => ThrowingMethod();

Expand All @@ -847,7 +847,7 @@ static ValueTask ThrowingMethod()
}

[Fact]
public static async ValueTask GotExpectedException()
public static async Task GotExpectedException()
{
static ValueTask testCode() => throw new ArgumentException("message", "paramName");

Expand All @@ -857,7 +857,7 @@ public static async ValueTask GotExpectedException()
}

[Fact]
public static async void MismatchedParameterName()
public static async Task MismatchedParameterName()
{
static ValueTask testCode() => throw new ArgumentException("message", "paramName2");

Expand Down
11 changes: 6 additions & 5 deletions test/test.xunit.assert/Asserts/PropertyAssertsTests.cs
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
using System.Threading.Tasks;
using NSubstitute;
using Xunit;
using Xunit.Sdk;
Expand Down Expand Up @@ -81,7 +82,7 @@ public class PropertyChangedAsync
{
#pragma warning disable CS1998
[Fact]
public async void GuardClauses()
public async Task GuardClauses()
{
var ex1 = await Assert.ThrowsAsync<ArgumentNullException>(() => Assert.PropertyChangedAsync(null!, "propertyName", async delegate { }));
Assert.Equal("object", ex1.ParamName);
Expand All @@ -91,7 +92,7 @@ public async void GuardClauses()
}

[Fact]
public async void ExceptionThrownWhenPropertyNotChanged()
public async Task ExceptionThrownWhenPropertyNotChanged()
{
var obj = new NotifiedClass();

Expand All @@ -104,7 +105,7 @@ public async void ExceptionThrownWhenPropertyNotChanged()
}

[Fact]
public async void ExceptionThrownWhenWrongPropertyChangedAsync()
public async Task ExceptionThrownWhenWrongPropertyChangedAsync()
{
var obj = new NotifiedClass();

Expand All @@ -117,7 +118,7 @@ public async void ExceptionThrownWhenWrongPropertyChangedAsync()
}

[Fact]
public async void NoExceptionThrownWhenPropertyChangedAsync()
public async Task NoExceptionThrownWhenPropertyChangedAsync()
{
var obj = new NotifiedClass();

Expand All @@ -129,7 +130,7 @@ public async void NoExceptionThrownWhenPropertyChangedAsync()
}

[Fact]
public async void NoExceptionThrownWhenMultiplePropertyChangesIncludesCorrectProperty()
public async Task NoExceptionThrownWhenMultiplePropertyChangesIncludesCorrectProperty()
{
var obj = new NotifiedClass();

Expand Down
Expand Up @@ -156,7 +156,7 @@ public static void DateTimeOffsetValue()
}

[Fact]
public static async void TaskValue()
public static async Task TaskValue()
{
var task = Task.Run(() => { });
await task;
Expand Down
7 changes: 4 additions & 3 deletions test/test.xunit.assert/Asserts/SkipAssertsTests.cs
Expand Up @@ -2,6 +2,7 @@

using System;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
using Xunit.v3;

Expand All @@ -16,7 +17,7 @@ public void GuardClause()
}

[Fact]
public async void AcceptanceTest()
public async Task AcceptanceTest()
{
var results = await RunAsync(typeof(ClassUnderTest));

Expand All @@ -43,7 +44,7 @@ public void GuardClause()
}

[Fact]
public async void AcceptanceTest()
public async Task AcceptanceTest()
{
var results = await RunAsync(typeof(ClassUnderTest));

Expand Down Expand Up @@ -81,7 +82,7 @@ public void GuardClause()
}

[Fact]
public async void AcceptanceTest()
public async Task AcceptanceTest()
{
var results = await RunAsync(typeof(ClassUnderTest));

Expand Down

0 comments on commit 7eba502

Please sign in to comment.