-
-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Capture.In<>() support System.Collections.Generic.Queue<>() #1198
Comments
Hi @Tiefseetauchner. ⚓🌊🐚 I understand the use case, but I'm not certain that a new
So what this boils down to is whether using For the time being, I would advise you to create e. g. an adapter extension method that wraps an Let's leave this issue open for a while and see what others think. If your request doesn't get much additional support, I'll eventually close this request; if other people want the same thing, we could add overloads for both Do you think this would be a sound approach? |
Hey! That sounds pretty reasonable indeed. Thx for the quick response 👍🏻 |
Thinking about this some more, I wonder whether it would make sense to make the following additions instead: partial static class Capture
{
public static T With<T>(Action<T> callback)
=> Capture.With(new CaptureMatch<T>(callback));
public static T With<T>(Action<T> callback, Expression<Func<T, bool>> predicate)
=> Capture.With(new CaptureMatch<T>(callback, predicate));
} This would make it a little easier to use any kind of collection:
and so on. It seems a little superfluous to me, but if we do end up doing anything about P.S.: Unfortunately, the three examples shown above don't work in practice; the C# compiler cannot infer the generic type argument automatically, so one would have to explicitly write e.g. |
This feature request hasn't seen any more upvotes nor other activity, so as per my original announcement above, I'm closing this. I'll mark the issue as "unresolved" though so we can more easily find it, should anyone want to pick this up in the future. |
I'm working on some test setups, and
Capture.In<>()
takesICollection<> collection
as parameter, but Queue only extendsICollection
. Queue would be really useful, because it makes it much easier to Validate the parameters in theVerify()
, since the Dequeue returns and removes the value, which means no helper method is needed, andTimes.Exactly()
could yeet as many entries as needed (if that is something that is possible, but it seems like it, from what I read inMock.Verify(Mock mock, LambdaExpression expression, Times times, string failMessage)
)I am not sure if a implementation over
ICollection
,IEnumerable<>
orQueue<>
directly would be best, but I shall leave that decision in this contributors capable hands, should they agree with my ascertation that supportingQueue<>
would be helpful(Edit: I am aware of
CaptureMatch
, but I think supportingQueue
directly would be more intuitive, and also there is no documentation on Capture and CaptureMatch that I could find, so it makes it even more confusing when using it. Overall, I think adding it would improve readability and ease of use)The text was updated successfully, but these errors were encountered: