web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Unit Test Case for ReadOnly properties

(0) ShareShare
ReportReport
Posted on by 362

Hi Everyone,

I am facing one issue while writing unit test cases for organization requests in CRM plugins. I have to write the unit test case for the below code but the properties "Processes" and "Entities" of "RetrieveProcessInstancesResponse" are read only and I couldn't assign values for these properties from my unit test case. I know we should create a wrapper class for this response to solve this issue but I couldn't figure out how to write wrapper class for the nested properties (for ex. Entities in my scenario) in "RetrieveProcessInstancesResponse" class.

public static Entity GetRunningBpfInstanceId(IOrganizationService service , string objectId, string entityName, ITracingService logger)
        {   
 
            var bpfInstance = new RetrieveProcessInstancesRequest
            {
                EntityId = new Guid(objectId),
                EntityLogicalName = entityName
            };

            var proResp = (RetrieveProcessInstancesResponse)service.Execute(bpfInstance);
            return proResp?.Processes.Entities?.FirstOrDefault() ?? null;
        }

Any help would be appreciated. 

Note: I am using "Microsoft Fakes Unit Test Framework” with Stub type.

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Hamza H Profile Picture

Hamza H 141

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 132

#3
DAnny3211 Profile Picture

DAnny3211 130

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans