Faked method taking IDictionary<,> as argument should accept Dictionary<,>
See original GitHub issueI’m mocking a interface that uses interfaces in it’s argument list
interface IBus {
Task Send(object commandMessage, IDictionary<string, string> optionalHeaders = null);
}
}
At runtime this method is called with an actual dictionary. This results in the following exception being thrown:
System.AggregateException: One or more errors occurred.
(The faked method has the signature (System.Object, System.Collections.Generic.IDictionary`2[System.String,System.String]),
but invokes was used with (System.Object, System.Collections.Generic.Dictionary`2[System.String,System.String]).)
---> FakeItEasy.Configuration.FakeConfigurationException:
The faked method has the signature (System.Object, System.Collections.Generic.IDictionary`2[System.String,System.String]),
but invokes was used with (System.Object, System.Collections.Generic.Dictionary`2[System.String,System.String]).
at FakeItEasy.ValueProducerSignatureHelper.AssertThatValueProducerSignatureSatisfiesCallSignature(MethodInfo callMethod, MethodInfo valueProducerMethod, String nameOfFeature) in C:\projects\fakeiteasy\src\FakeItEasy\ValueProducerSignatureHelper.cs:line 22
How can I make a fake accept this kind of calls?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
swift - How do i pass a dictionary as a function parameter?
I'm not sure what you're trying to do with ABRecordRef <AnyObject, AnyObject> , but the <> syntax is for specifying a generic type....
Read more >Taking a dictionary as an argument is the root of all evil
Instead of taking specific/clear arguments, these functions take some mysterious params dictionary with lord knows what in it.
Read more >Is it bad design to pass around a dictionary of arguments ...
When all your methods take a dictionary, they A) do not give the reader of the code information on what parameters they need, ......
Read more >Python: Passing Dictionary as Arguments to Function
In Python, everything is an object, so the dictionary can be passed as an argument to a function like other variables are passed....
Read more >Dictionary — Godot Engine (stable) documentation in English
A built-in data structure that holds key-value pairs. Description: Dictionaries are associative containers that contain values referenced by unique keys.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry. I’m wasting your time here. Of cause you are right. There was a call-setup with an invoke hidden in the test setup, and of cause it was using
Dictionary
instead ofIDictionary
.Always glad to help!