Skip to content

Convert TestDelegate and ActualValueDelegate to Action and Func<T> #4824

@stevenaw

Description

@stevenaw

Discussed in #4823

Originally posted by Dreamescaper September 13, 2024
Is there any reason not to use Action and Func<T> instead? Since Action and Func<T> are natural types for delegates in C#, using other delegates causes some confusion, e.g. here:

        var getActual = () => "/* get actual value */";
        Assert.That(getActual, Is.EqualTo("expectedValue").After(10000, 500));

Since I'm passing a delegate to Assert method, I'd expect a delegate overload to be invoked. Instead, non-delegate TActual overload is used, and assertion fails - because getActual is Func<string>, not ActualValueDelegate<TActual>.

Therefore, my question is. Would it make sense to to replace TestDelegate and ActualValueDelegate with Action and Func<T> in the next major version?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeIndicates resolving the issue will be a breaking change and will require it to be in a major versionis:enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions