-
-
Notifications
You must be signed in to change notification settings - Fork 95
Closed
Description
Hi,
Consider this test with xUnit.net assertions:
public class User
{
public required string Name { get; set; }
public required int Age { get; set; }
}
public class ConversionTest
{
[Test]
public async Task ConvertAssertAll()
{
User[] users =
[
new () { Name = "Alice", Age = 30 },
new () { Name = "Bob", Age = 25 }
];
Xunit.Assert.All(users, user =>
{
Xunit.Assert.NotNull(user.Name);
Xunit.Assert.True(user.Age > 18);
});
}
}The fixer for Assert.All produces incorrect code in the form of Assert.That(callback).All().Satisfy(testSubject):
TUnit.Assertions.Assert.That(user =>
{
Xunit.Assert.NotNull(user.Name);
Xunit.Assert.True(user.Age > 18);
}).All().Satisfy(users);Based on discussion in #3766, I don't think this should use All().Satisfy(), but rather something like this:
using (TUnit.Assertions.Assert.Multiple())
{
foreach (User user in users)
{
Xunit.Assert.NotNull(user.Name);
Xunit.Assert.True(user.Age > 18);
}
}Metadata
Metadata
Assignees
Labels
No labels