You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But of course this only matches if the caller passes in the base Command, not a derived class such as AddUserCommand.
Then I came across the newly added Arg.AnyType and thought this was perfect for my needs but I can't get the syntax right. The remark on the method comments seems to indicate that I need to create a derived class but I'm not sure I can for this specific case... "If the generic type parameter has constraints, you will have to create a derived class/struct that implements those constraints." This was the attempt, it fails because now I am back to having a derived type which never matches
public record AnyCommand : Command, Arg.AnyType;
harness.CommandFactory
.New(Arg.Any<Func<AnyCommand>>())
.Returns(r => r.Arg<Func<Command>>()());
Does anyone have an idea how/if this can be achieved?
Question
Hello. I am trying to mock out this method so that any time it is called the Func is invoked and T is returned.
T New<T>(Func<T> instantiate) where T : Command;
Command is a base class for all of my commands. I thought I could do this
But of course this only matches if the caller passes in the base Command, not a derived class such as AddUserCommand.
Then I came across the newly added Arg.AnyType and thought this was perfect for my needs but I can't get the syntax right. The remark on the method comments seems to indicate that I need to create a derived class but I'm not sure I can for this specific case... "If the generic type parameter has constraints, you will have to create a derived class/struct that implements those constraints." This was the attempt, it fails because now I am back to having a derived type which never matches
Does anyone have an idea how/if this can be achieved?
Related links
The text was updated successfully, but these errors were encountered: