Q:

Moq + Unit Testing + System. Reflection. TargetParameterCountException: Parameter Count mismatch

I am getting a "System. Reflection. TargetParameterCountException: Parameter Count mismatch" exception when attempting to mock our ApiClient. 
I am using the following code to Setup the Moq response
private void SetupApiClientForGetZones(IEnumerable<Zone> zone)
{
    this. MockHubApiClient. Setup(x => x.GetAsync<IEnumerable<Zone>>(It. IsAny<string>(), It. IsAny<IDictionary<string, string>>()))
                .Returns(
                    (string name) =>
                    {
                        return zone == null ?  Task. FromResult<IEnumerable<Zone>>(null) : Task. Run(() => zone);
                    });

            this. MockApiClientFactory. Setup(x => x.CreateClient(It. IsAny<string>()))
                .Returns(this. MockHubApiClient. Object);
        }

The iApiClient interface I attempting to Mock is
public interface IApiClientAsync : IApiClient
    {
        Task<string> GetAsync(string apiController);

        Task<T> GetAsync<T>(string apiController) where T : class;

        Task<string> GetAsync(string apiController, IDictionary<string, string> param, string queryString);

        Task<T> GetAsync<T>(string apiController, IDictionary<string, string> param) where T : class;
}

My unit test is
[Test]
public void GetZonesNotCached()
{
    var data = new List<Zone> { new Zone { ZoneId = 1, ZoneName = "Test Zone 1" }, new Zone { ZoneId = 2, ZoneName = "Test Zone 2" } };

    this. SetupApiClientForGetZones(data);

    this. MockCache. Setup(x => x.GetItemFromCache<IEnumerable<Zone>>(It. IsAny<string>()));

    var organisationService = new OrganisationService(this. MockUnitOfWorkAsync. Object, this. MockApiClientFactory. Object, this. MockCache. Object);

    var results = organisationService. GetZones(1, 1).ToList();

    Assert. IsNotNull(results);
    Assert. AreEqual(3, results. Count, "There should be 3 records returned");

    this. MockCache. Verify(x => x.GetItemFromCache<IEnumerable<Zone>>(It. IsAny<string>()), Times. Once());
    this. MockHubApiClient. Verify(x => x.GetAsync<IEnumerable<Zone>>(It. IsAny<string>(), It. IsAny<IDictionary<string, string>>()), Times. Once());
}

I have found numerous other posts with the same exception but none of the solutions or examples are the same as mine. 
I have been able to successfully Mock the response when calling the GetAsync method that only has the single string paramter. 
    private void SetupApiClientForAllDealerDetails(IEnumerable<DealerDetail> dealerDetails)
    {
        this. MockHubApiClient. Setup(
            x => x.GetAsync<IEnumerable<DealerDetail>>(It. IsAny<string>()))
            .Returns(
                (string name) =>
                {
                    return dealerDetails == null ?  Task. FromResult<IEnumerable<DealerDetail>>(null) : Task. Run(() => dealerDetails);
                });

        this. MockApiClientFactory. Setup(x => x.CreateClient(It. IsAny<string>()))
            .Returns(this. MockHubApiClient. Object);
    }

Any ideas anyone? 

A:

If you use an expression in your .Returns instead of a value, then that expression's parameters must match those of the method signature you are mocking. 
For example, I found this in SetupApiClientForGetZones:
this. MockHubApiClient. Setup(x => x.GetAsync<IEnumerable<Zone>>(It. IsAny<string>(), It. IsAny<IDictionary<string, string>>()))
                .Returns(
                    (string name) =>
                      {
                        return zone == null ?  Task. FromResult<IEnumerable<Zone>>(null) : Task. Run(() => zone);
                      });

When really it should be:
this. MockHubApiClient. Setup(x => x.GetAsync<IEnumerable<Zone>>(It. IsAny<string>(), It. IsAny<IDictionary<string, string>>()))
                .Returns<string, IDictionary<string, string>>(
                    (name, dict) =>
                      {
                        return zone == null ?  Task. FromResult<IEnumerable<Zone>>(null) : Task. Run(() => zone);
                      });

