Skip to content

Commit

Permalink
Convert tests from 'async void' to 'async Task'
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Apr 13, 2024
1 parent f861ac4 commit 0d61dbf
Show file tree
Hide file tree
Showing 107 changed files with 732 additions and 628 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Xunit;
using Verify = CSharpVerifier<Xunit.Analyzers.ClassDataAttributeMustPointAtValidClass>;

Expand All @@ -13,7 +14,7 @@ public void TestMethod() { }
}";

[Fact]
public async void SuccessCase()
public async Task SuccessCase()
{
var dataClassSource = @"
using System.Collections;
Expand Down Expand Up @@ -81,7 +82,7 @@ private DataClass() { }

[Theory]
[MemberData(nameof(FailureCases))]
public async void FailureCase(string dataClassSource)
public async Task FailureCase(string dataClassSource)
{
var expected =
Verify
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Threading.Tasks;
using Xunit;
using Verify = CSharpVerifier<Xunit.Analyzers.CollectionDefinitionClassesMustBePublic>;

public class CollectionDefinitionClassesMustBePublicTests
{
[Fact]
public async void ForPublicClass_DoesNotFindError()
public async Task ForPublicClass_DoesNotFindError()
{
var source = @"
[Xunit.CollectionDefinition(""MyCollection"")]
Expand All @@ -16,7 +17,7 @@ public class CollectionDefinitionClass { }";
[Theory]
[InlineData("")]
[InlineData("internal ")]
public async void ForFriendOrInternalClass_FindsError(string classAccessModifier)
public async Task ForFriendOrInternalClass_FindsError(string classAccessModifier)
{
var source = $@"
[Xunit.CollectionDefinition(""MyCollection"")]
Expand All @@ -32,7 +33,7 @@ public async void ForFriendOrInternalClass_FindsError(string classAccessModifier
[Theory]
[InlineData("")]
[InlineData("public ")]
public async void ForPartialClassInSameFile_WhenClassIsPublic_DoesNotFindError(string otherPartAccessModifier)
public async Task ForPartialClassInSameFile_WhenClassIsPublic_DoesNotFindError(string otherPartAccessModifier)
{
var source = $@"
[Xunit.CollectionDefinition(""MyCollection"")]
Expand All @@ -46,7 +47,7 @@ public partial class CollectionDefinitionClass {{ }}
[InlineData("", "")]
[InlineData("", "internal ")]
[InlineData("internal ", "internal ")]
public async void ForPartialClassInSameFile_WhenClassIsNonPublic_FindsError(
public async Task ForPartialClassInSameFile_WhenClassIsNonPublic_FindsError(
string part1AccessModifier,
string part2AccessModifier)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Xunit;
using Verify = CSharpVerifier<Xunit.Analyzers.ConstructorsOnFactAttributeSubclassShouldBePublic>;

public class ConstructorsOnFactAttributeSubclassShouldBePublicTests
{
[Fact]
public async void DefaultConstructor_DoesNotTrigger()
public async Task DefaultConstructor_DoesNotTrigger()
{
var source = @"
using System;
Expand All @@ -26,7 +27,7 @@ public void TestFact() { }
}

[Fact]
public async void ParameterlessPublicConstructor_DoesNotTrigger()
public async Task ParameterlessPublicConstructor_DoesNotTrigger()
{
var source = @"
using System;
Expand All @@ -51,7 +52,7 @@ public void TestFact() { }
}

[Fact]
public async void PublicConstructorWithParameters_DoesNotTrigger()
public async Task PublicConstructorWithParameters_DoesNotTrigger()
{
var source = @"
using System;
Expand All @@ -76,7 +77,7 @@ public void TestFact() { }
}

[Fact]
public async void PublicConstructorWithOtherConstructors_DoesNotTrigger()
public async Task PublicConstructorWithOtherConstructors_DoesNotTrigger()
{
var source = @"
using System;
Expand Down Expand Up @@ -105,7 +106,7 @@ public void TestFact() { }
}

[Fact]
public async void InternalConstructor_Triggers()
public async Task InternalConstructor_Triggers()
{
var source = @"
using System;
Expand Down Expand Up @@ -134,7 +135,7 @@ public void TestFact() { }
}

[Fact]
public async void ProtectedInternalConstructor_Triggers()
public async Task ProtectedInternalConstructor_Triggers()
{
var source = @"
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Threading.Tasks;
using Xunit;
using Verify = CSharpVerifier<Xunit.Analyzers.DataAttributeShouldBeUsedOnATheory>;

public class DataAttributeShouldBeUsedOnATheoryTests
{
[Fact]
public async void DoesNotFindErrorForFactMethodWithNoDataAttributes()
public async Task DoesNotFindErrorForFactMethodWithNoDataAttributes()
{
var source = @"
public class TestClass {
Expand All @@ -19,7 +20,7 @@ public void TestMethod() { }
[InlineData("InlineData")]
[InlineData("MemberData(\"\")")]
[InlineData("ClassData(typeof(string))")]
public async void DoesNotFindErrorForFactMethodWithDataAttributes(string dataAttribute)
public async Task DoesNotFindErrorForFactMethodWithDataAttributes(string dataAttribute)
{
var source = $@"
public class TestClass {{
Expand All @@ -35,7 +36,7 @@ public void TestMethod() {{ }}
[InlineData("InlineData")]
[InlineData("MemberData(\"\")")]
[InlineData("ClassData(typeof(string))")]
public async void DoesNotFindErrorForTheoryMethodWithDataAttributes(string dataAttribute)
public async Task DoesNotFindErrorForTheoryMethodWithDataAttributes(string dataAttribute)
{
var source = $@"
public class TestClass {{
Expand All @@ -51,7 +52,7 @@ public void TestMethod() {{ }}
[InlineData("InlineData")]
[InlineData("MemberData(\"\")")]
[InlineData("ClassData(typeof(string))")]
public async void FindsErrorForMethodsWithDataAttributesButNotFactOrTheory(string dataAttribute)
public async Task FindsErrorForMethodsWithDataAttributesButNotFactOrTheory(string dataAttribute)
{
var source = $@"
public class TestClass {{
Expand Down
Loading

0 comments on commit 0d61dbf

Please sign in to comment.