mardi 13 avril 2021

NSubstitute: Match on any Dictionary with explicit args?

I'm willing to bet that a question this generic already has an answer but I haven't had success in finding it yet so here goes:

With NSubstitute, how can I match on 'any' Dictionary -- so long as it contains a certain set of key-value pairs?

The following will match any Dictionary

mockObject.Received().Method(Arg.Any<Dictionary<string, string>>());

But I'd like to be able to match any Dictionary so long as it has the given key-value pairs -- for example, I'd like to do something like:

mockObject.Received().Method(Arg.Any<Dictionary<string, string>> { {"MyKey": "MyValue"} });

Does something like that exist in NSubstitute?

Aucun commentaire:

Enregistrer un commentaire