-
-
Notifications
You must be signed in to change notification settings - Fork 114
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
The following xUnit test will not have the inner item assertions converted.
[Fact]
public void TestWithAssertAll()
{
var items = new[] { 1, 2, 3 };
Assert.All(items, item =>
{
Assert.True(item > 0);
Assert.True(item < 10);
Assert.NotEqual(0, item);
});
}Expected Behavior
Ideally, an overload of All that takes an async delegate and allows for nested awaited TUnit assertions, perhaps working in a similar way for Assert.Multiple() for each nested item? Like this:
await Assert.That(items).All(async item =>
{
await Assert.That(item > 0).IsTrue();
await Assert.That(item < 10).IsTrue();
await Assert.That(item).IsNotEqualTo(0);
});Or, failing that, to just have the assertion be converted to a foreach loop:
foreach (var item in items)
{
await Assert.That(item > 0).IsTrue();
await Assert.That(item < 10).IsTrue();
await Assert.That(item).IsNotEqualTo(0);
};Actual Behavior
Fixer produces the following, which is not a valid way to use TUnit's All assertion, and inner assertions are left as xUnit assertions.
await Assert.That(items).All(item =>
{
Assert.True(item > 0);
Assert.True(item < 10);
Assert.NotEqual(0, item);
});Steps to Reproduce
Run xUnit code fixer on the code in the description above.
TUnit Version
1.14.0
.NET Version
.NET 10
Operating System
Windows
IDE / Test Runner
dotnet CLI (dotnet test / dotnet run)
Error Output / Stack Trace
Additional Context
No response
IDE-Specific Issue?
- I've confirmed this issue occurs when running via
dotnet testordotnet run, not just in my IDE
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working