Skip to content

xUnit Migration: Assert.All converted to non-existent AllSatisfy method #4335

Description

@thomhurst

Description

When using the TUnit xUnit migration code fixer (TUXU0001), the fixer converts xUnit's Assert.All() to .AllSatisfy(), but this method doesn't exist on TUnit's collection assertions, resulting in CS1061 compilation errors.

Steps to Reproduce

  1. Create an xUnit test using Assert.All():
using Xunit;

[Fact]
public void Test_All_Items()
{
    var items = new[] { 1, 2, 3 };
    Assert.All(items, item => Assert.True(item > 0));
}
  1. Install TUnit package and run dotnet format analyzers --severity info --diagnostics TUXU0001

Expected Behavior

The code should be converted to valid TUnit syntax. If .AllSatisfy() doesn't exist, either:

  1. The method should be added to TUnit, or
  2. The fixer should convert to an existing TUnit pattern

Actual Behavior

The code is converted to:

[Test]
public async Task Test_All_Items()
{
    var items = new[] { 1, 2, 3 };
    await Assert.That(items).AllSatisfy(item => Assert.True(item > 0));
}

This causes:

error CS1061: 'CollectionAssertion<int>' does not contain a definition for 'AllSatisfy' and no accessible extension method 'AllSatisfy' accepting a first argument of type 'CollectionAssertion<int>' could be found

Affected Assertion Types

The issue affects multiple collection assertion types:

  • CollectionAssertion<T>
  • ReadOnlyListAssertion<T>

Impact

This affects tests that validate all items in a collection satisfy a condition. In the Moq test suite, this resulted in 28+ compilation errors.

Environment

  • TUnit Version: 1.9.91
  • .NET SDK: 10.0.101
  • OS: Windows

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions