This excellent article:
alexanderdevelopment.net/.../how-to-unit-test-c-dynamics-crm-interface-code-part-iii
demonstrates how it is possible to mock a RetrieveAttributeResponse to enable Unit Testing of plugin code which uses this Response class. It creates a wrapper class which can be used in the Unit Test.
I've been using this method to mock not only the RetrieveAttributeResponse, but also the RetrieveMultipleResponse and RetrieveEntityResponse classes.
However, I've hit a problem when trying to work with my RetrieveEntityResponseWrapper. The response needs to contain an instance of EntityMetadata, which I can instantiate in my mocked response. However, I need to set the Attributes property of the EntityMetadata, which is a read-only property.
So in some way I need to have a wrapped class within a wrapped class, and I don't see how I can do this?
Is what I'm trying to do possible - can I mock the read-only Attributes property of the EntityMetadata property of my RetrieveEntityResponseWrapper?
Many thanks for your thoughts,
Ben
*This post is locked for comments
I have the same question (0)