How to fake multiple queries in Plugin

Sep 2, 2015 at 12:57 PM
Edited Sep 2, 2015 at 1:07 PM
How do we handle a situation like below?

Let's say a post create plugin updates Country field of a Contact to the UK, however before updating that we verify in plugin that contact's age is greater than 18 which we can fake and get results by using base.OrganizationServiceStub.RetrieveMultipleQueryBase however we have an other query after that which get's contact's parent account data... How do we fake/stub this? can we handle multiple queries in unit testing using xrm test framework and if we do how do we differentiate it from first one or better to go with integration testing?

Sep 6, 2015 at 6:31 PM
Hi Rokhri, you could fake different queries checking the QueryExpression.

Let me know if that makes sense.

Marked as answer by rokhri on 9/7/2015 at 3:20 AM
Sep 6, 2015 at 9:47 PM
Thanks Ramon.

I was trying with FetchExpression due to existing code but could't find a way of differentiating between multiple queries and calls at different stages in code.

I'll change this to QueryExpression and see how I get on.