Moq.Dapper
Moq.Dapper copied to clipboard
Do not support for multimapping
Am trying to mock multimapping using this library and am not getting the support for the same. Here is the multi mapping query. `string sql = "SELECT * FROM Invoice AS A INNER JOIN InvoiceDetail AS B ON A.InvoiceID = B.InvoiceID;";
using (var connection = My.ConnectionFactory()) { connection.Open();
var invoices = connection.Query<Invoice, InvoiceDetail, Invoice>(
sql,
(invoice, invoiceDetail) =>
{
invoice.InvoiceDetail = invoiceDetail;
return invoice;
},
splitOn: "InvoiceID")
.Distinct()
.ToList();
}`
Am trying to Mock this using the below code but am not able to achieve this? Can you resolve this as this methods everybody uses.
mockConnection.SetupDapper(c => c.Query<Invoice, InvoiceDetail, Invoice>(It.IsAny<string>(), null, null, null, true, "", null)) .Returns(fakeInvoice);
I'm having the same problem. Has anyone solved this?
I've come across this issue also. Has anyone found a workaround for this?
I am also having issues writing tests around this. Anyone else managed to get test this functionality?
I have same problem. Have anyone solved this issue?
Same issue, any updates?
Same issue
I have same problem. Have anyone solved this issue?
This project seems to be dead. Any alternative guys ?
I've asked the same question here: https://stackoverflow.com/q/74370722/495455, hopefully in the future the solution is simple!
When trying to mock the multi-mapping query with following code, but did not get expected value.
connection.SetupDapper(c => c.Query<obj1, obj2, obj1>(
It.IsAny<string>(),
It.IsAny<Func<obj1, obj2, obj1>>(),
It.IsAny<It.IsAnyType>(),
It.IsAny<IDbTransaction>(), It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<CommandType>()))
.Returns(expectedListOfObj1);
Only the int properties returns correctly, but string properties returns null.
var queryStr = "Select * from obj1 left join obj2 on obj2.obj2Id = obj1.obj2Id Where obj1value = @obj1value";
var actual= dbConnection.Query<obj1, obj2, obj1>(
queryStr,
(a, t) => {
a.obj2 = obj2; return obj1;
},
new { obj1value },
splitOn: "obj2Id");