C# – Unit Testing RIA Services

csilverlightsilverlight-3.0

I have a domain services class that runs on the server in a silverlight application. I.e. the class is defined like this,

public class UpgradeToolDomainService : DomainService
{
...
}

I am using RIA services which means that on the client it generates code which looks like this,

public sealed partial class UpgradeToolDomainContext : DomainContext
{
...
}

The problem with that is I would like to mock the UpgradeToolDomainContext using Rhino mocks when unit testing my client side code, but the class is sealed and Rhino mocks doesn't support mocking sealed classes.

What do you think?? I.e. is it possible to change the generated code to not be sealed? Or any other obvious solution?

Best Answer

For the moment what I have done is create a partial class UpgradeToolDomainContext. I have made this class implement an interface. I am using this interface to create my mocks with.

Any better suggestions are welcome.