3

also, what day is today and why do I have an ugly unicorn as my avatar ;-)

2
  • wow! two votes to close within a minute of posting question... lighten up, smile and then get back to code ;-) Commented Apr 1, 2010 at 21:57
  • LOL..people around here are really trigger happy Commented Apr 2, 2010 at 3:00

2 Answers 2

6

First, you have to use sealed classes and singletons everywhere -- none of these wrapper classes with virtual methods that can be mocked out or anything. Next, and this is important, you have to use Reponse.Write instead of returning views. It also helps to serialize the contents of all of the form parameters, encrypt them, and store them in a hidden input on the page -- then always check the new parameters against the old ones to see which things changed. Using this way you can generate these things called "events" -- they're just like button clicks and selects on Windows Forms. These are much easier to understand and simulate in your unit tests.

Sign up to request clarification or add additional context in comments.

3 Comments

thanks! so basically I have to start by making all of my classes static correct? making sure it is next to impossible to mock them... thanks, that's a start :)
yep -- then make sure you have several events in your controller that have to be invoked in the proper sequence to "set up" the state of your controller. I'd suggest events like "Init", "PageLoad", "PreRender", that sort of thing. It's also important that you be able to configure things like data sources in the HTML of the view where your controller can look it up and use it for the data binding event.
Also, attach a LeprechaunOverlord to each class. ASP.NET MVC markup isn't nearly as ugly as ASP.NET WebForms markup, doesn't have VIEWSTATE XSS vulnerabilities etc. So we like to use the Leprechaun in this case.
1

You have a unicorn because today is April Fools Day and Jeff is a sucker for that kind of thing.

Some would say an MVC site is more testable than a ASP.NET Forms one. You make it testable by adding tests I guess.

1 Comment

I don't understand why this was down voted, up voting to off set it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.