question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Faked method taking IDictionary<,> as argument should accept Dictionary<,>

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vegarcommented, Mar 10, 2020

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 of IDictionary.

0reactions
thomaslevesquecommented, Mar 10, 2020

Always glad to help!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found