sequenceSetup.ReturnsRange(Enumerable.Repeat(lastValue, int.MaxValue))though that hasn't been implemented. We've briefly discussed this in moq/moq4#573.
mock.SetReturnsDefault. (Though take note that this is not specific to one method setup, but to all of a mock's methods.)
Argumentsget boxed as
objects (boxing isn't allowed for by-ref structs, i.e. stack-only types). But as far as my current understanding of Moq 5 goes, that at least would be a limitation caused by its own API, and not by the underlying technology.
MethodInfoetc. Try to do something with the much lower-level System.Reflection.Metadata or Mono.Cecil, and you'll soon see what System.Reflection provides beyond those. Like other parts in the BCL (say, LINQ expression trees, or CodeDOM), Reflection would ideally be updated together with C# language innovation... and that hasn't fully happened for quite a few years now. For example, try
DynamicInvoke-ing a delegate that has spans in its signature; or try reflecting over all the custom modifiers that the C# compiler rmits these days. Yes, Reflection isn't the only limiting factor. You're already aware of some LINQ expression tree limitations (no assignment, no
await, no default parameters, etc.) though Moq 4 can partly work around rhose. But at the end of the day, those parts of the BCL lag behind Roslyn.
objectarray. This cannot be done for spans because they are stack-only types that cannot be boxed (i.e. converted to
object). There is no way around this.
Hey moq creators! Nice library. I really like it, and use it daily.
I have alot of discussions about strict mocking vs. loose mocking. I know Loose mocking is the default. I have tried to find out why that is, but I cant seem to find anything about it. Can you explain why that is?
I do prefer loose mocking, and just stubbing the relevant methods for my Assert. When is Strict preffered?
Hi, I'm trying to raise the following event but i'm getting a Parater count mismatch exception, any ideas?
event Func<ProcessMessageEventArgs, Task> ProcessMessageAsync;
processorMock.Raise(c => c.ProcessMessageAsync += null, new ProcessMessageEventArgs(msgMock.Object, receiverMock.Object, CancellationToken.None));