-
-
Notifications
You must be signed in to change notification settings - Fork 114
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
The following generated assertion is not available because of a type mismatch between the generated extension ContainsMessage(this IAssertionSource<string[]> source, ...) and the actual return type of Assert.That(), which is CollectionAssertion<string>.
public class UnitTest1
{
[Test]
public async Task Test1()
{
string[] items = new[] { "food", "bard" };
await Assert.That(items).ContainsMessage("foo", false);
}
}
public static partial class Assertions
{
[EditorBrowsable(EditorBrowsableState.Never)]
[GenerateAssertion(ExpectationMessage = "to contain message '{needle}'")]
public static bool ContainsMessage(this string[] strings, string needle, bool exact = true)
{
return strings.Any(x => exact ? x == needle : x.Contains(needle));
}
}Expected Behavior
Generated assertion is available when assertion target is a concrete collection.
Actual Behavior
Assertion not available.
Steps to Reproduce
See above code.
TUnit Version
1.15.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
Labels
bugSomething isn't workingSomething isn't working