Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

asp.net - How to unit test for turning off request validation? -


i'm new @ tdd thing making serious effort, i'm hoping feedback here.

i created little web service minify javascript, , nice, tests passing. noticed bug: if tried minify alert('<script>');, throw httprequestvalidationexception.

so that's easy enough fix. i'll add [allowhtml] controller. way unit test doesn't happen in future?

the following first thought:

[testmethod] public void minify_doesntchokeonhtml() {     try     {         using (var controller = servicelocator.current.getinstance<minifycontroller>())         {             return controller.minify("alert('<script></script>');");         }     }     catch (httprequestvalidationexception)     {         assert.fail("request validation prevented html existing inside javascript.");     } } 

however, doesn't work since getting controller instance , running methods on it, instead of firing whole asp.net pipeline.

what unit test this? maybe reflector on controller method see if [allowhtml] attribute present? seems structural, , unlikely survive refactoring; functional might make more sense. ideas?

you have 2 options:

first

write integration test hosts mvc in-proc or runs using browser (using watin instance) cover scenario.

second

write unit test check method marked needed attribute.

i go first option.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -