tags:

views:

158

answers:

2

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)?

A: 

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?

toxvaerd
Execute is an overridden method from within the workflow system. In the end I have just kept that element really thin and extracted the code to another testable class.
BlackWasp
A: 

Maybe the answers to this question will be useful for you: http://stackoverflow.com/questions/1582596/how-do-i-moq-the-system-io-fileinfo-class-or-any-other-class-without-an-interf

Konamiman