Moq.Dapper icon indicating copy to clipboard operation
Moq.Dapper copied to clipboard

Accessing the params argument in the ReturnsAsync

Open roly445 opened this issue 5 years ago • 3 comments

If I call a query with parameters is there currently anyway to access those values in the ReturnsAsync method? I need to access the data in my tests and store it for another query to use it.

Thanks

roly445 avatar Aug 27 '19 14:08 roly445

Hi @roly445, can you please provide some sample code? I am not sure I understand the scenario as it sounds like you could simply use a variable for constant values.

UnoSD avatar Sep 13 '19 16:09 UnoSD

I'm running into this issue when trying to do something like this:

connection.SetupDapperAsync(c => c.QueryAsync<string>(It.IsAny<string>(), It.IsAny<object>(), null, null, CommandType.StoredProcedure))
    .ReturnsAsync((string s, object o) => new [] 
    {
        SuccessfulCall(s, o)
    });
public static string SuccessfulCall(string proc, obj param) => $"{proc} successfully called with param {JsonSerializer.Serialize(param)}!";

Dessyreqt avatar Dec 23 '19 16:12 Dessyreqt

I've also run into this issue recently. Did either of you find what the issue was, or perhaps another way to achieve this, @roly445 @Dessyreqt?

abxhub avatar Apr 27 '22 10:04 abxhub