You may want to refactor your validator logic into a more testable, standalone component. Create a mockable wrapper for the HttpContext stuff.
Then, create a RequestValidator implementation which simply delegates to your standalone component. This will allow you to test the logic of your validator, but then you'll need an integration test to make sure you've wired everything up correctly in your actual RequestValidator implementation. --- Patrick Steele http://weblogs.asp.net/psteele On Tue, Jun 29, 2010 at 9:15 PM, scott_m <[email protected]> wrote: > I wrote a custom RequestValidator implementation (http:// > msdn.microsoft.com/en-us/library/ > system.web.util.requestvalidator.aspx) to deal with W.I.F. security > tokens. Now I am trying to write a unit test for this class. It's > turning out to be more difficult that I anticipated. > > > > 1. This method is protected internal. Even using > InternalsVisibleToAttribute, I am having no luck being able have my > unit test compile against my implementation of: > > bool IsValidRequestString(HttpContext context, string value, > RequestValidationSource rvs, string collectionKey, out int > validationFailureIndex) > > > > 2. The HttpContext class used by this method is sealed so I am not > sure how to mock one up with Rhino.Mocks. > > > Anyone have any tips for making the RequestValidator testable? > > > thanks > > -- > You received this message because you are subscribed to the Google Groups > "Rhino.Mocks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rhinomocks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en.
