Question

This class is sealed but I need to mock it using Moq for use in a CRM workflow development for calling the method:

    protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)

How can I do this or get around the problem by creating an instance of ActivityExecutionContext (which has no public constructor)?

Was it helpful?

Solution

I don't think you have many options besides creating a wrapper/proxy you can use in your code, which you then can mock.

I'm not sure I understand your question right though, is the class in essence a singleton? If so here's a great link explaining how to work around singletons when unit testing.

Is it possible for you to change the implementation of Execute?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top