开发者

Testing ria services authentication with moq

I'm using RIA Services authentication in a Silverlight app and it works great. Now I want to add unit tests using Moq framework: http://code.google.com/p/moq/

The problem I'm having is that I can't simulate none of the methods exposed by WebContext.Current.Authentication, since I can't return 开发者_开发问答custom values for the mocked methods. For example, I can't simulate a successful login since I can't set a value for LoadUserOperation.IsComplete because that property doesn't have a public setter. The same happens with all the returned structures: they are readonly!

Is there a way I can simulate the authentication operations and therefore test the login in my app?

Thanks in advance.


I show how to mock authentication in this post.


Thanks for you help. I found a solution after refactoring the code a little bit and adding proper interfaces and wrappers for the RIA services sealed classes. This guy shows how.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜