Open psyciknz opened 2 years ago
Hello,
That's a good question that I will add in the documentation.
It's easy: you can add multiple Mocks.When
for the same MockDbConnection
.
conn.Mocks
.When(cmd => cmd.CommandText.StartsWith("SELECT 1 FROM "))
.ReturnsScalar<int>(1);
conn.Mocks
.When(cmd => cmd.CommandText.StartsWith("SELECT 2 FROM "))
.ReturnsScalar<int>(2);
Don't forget that you have also the method WhenTag
to help you to detect the correct SQL Query.
See https://apps72.com/dbmocker/conditions.html#whentag
Hey thanks for the answer overngiht.
I did see the tagging, but correct me if I'm wrong, tagging a command/query etc is not part of the out of the box system.data.x namespaces is it?
I have managed to successfully mock a query using:
Then in one method I have the following query that matches teh command text:
But then further down in teh same method I have
How can I add a mock result for startswith("Select 2 from")
Regards