This project is read-only.

Is there a way to unit test LINQ queries?

Aug 12, 2014 at 7:38 AM
How to setup the unit test for CRM LINQ plugins?

And how to set statecode of an entity in SetupPlugin()?
Aug 12, 2014 at 9:18 AM
I've found that I can use OrganizationServiceStub.ExecuteOrganizationRequest to inject LINQ results.

Use Entity to set statecode instead of set it in early bound object. Early bound object can also use Attribute.Add to add statecode.

Next question:

It seems ExecuteOrganizationRequest or RetrieveMultipleQueryBase only setup and returns the query results. How can we test a complex query logic is working though?

For example, anyway I can setup a bunch of records of a entity, then the query actually query the entity collection base on its logic, and perhaps only returns one matching record?
Aug 15, 2014 at 9:42 PM
The unit in this case is more useful for testing the query that your plug-in is generating (i.e. if you plug-in is building the query you expect to execute) and what your plug-in is doing with the results. If you want ensure that your query actually works, then an integration test would be suitable for that.