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

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 151 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 134

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 55 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans