views:

295

answers:

1

I'm attempting to write some tests using the Silverlight Unit Test Framework (the unsupported, unofficial MS library Microsoft.Silverlight.Testing). I need to impersonate three different users when testing some functionality of our application.

Our application is for internal use at our company, so the authenticated user may get different functionality based on security groups they are members of (e.g. read/write permission, read-only, no access).

The Microsoft.VisualStudio.TestTools.UnitTesting.Web namespace has the CredentialAttribute for impersonating different users when testing an ASP.NET app, but that's not available in Microsoft.Silverlight.Testing.

Any suggestions on how to accomplish this? The simplest working solution will win a prize (my never-ending appreciation)!

+2  A: 

Everything in the Silverlight unit test framework (and Silverlight platform) is going to be truly client-side, so what you're talking about is changing the authenticated user to the server, and its web services, I assume.

That's a difficult task, instead I'd recommend mocking the business objects/logic to allow you to swap out the underlying user type for your testing.

Jeff Wilcox