views:

129

answers:

5

Hi guys,

i know MVC is the future but for some of us still stuck in the good old webform land, i'm trying to learn how to do TDD and introduce better testing for our current application...

basically the asp.net 2.0 c# web app is quite complicated with some logic in sproc, some in the javascript via json data processing, some in user controls and some in the code behind. not to mention some libraries here and there to make it merrier.

i have literally no idea how to even begin to break things down to smaller chunks to do any testing.

from so i can only find this related question which doesn't really help much. and i kind of like this simplistic way of getting things started but was looking for more comprehensive samples.

Any help in source code, tutorials, etc would be nice :) thanks!

+3  A: 

Model View Presenter pattern with Castle in ASP.NET (with ASP.NET WebForms )

Leniel Macaferi
thanks but do you have any more with test codes attached? :)
melaos
A: 

Dino Esposito's book worked pretty well for me. LOTS of detail, including IIS7. But I also took a course paid for by my company that added lots of detail.

Javascript and JSON ultimately are not part of ASP.NET MVC. ASP.NET MVC supports them. The difference may be subtle, but for breaking things down into manageable chunks for learning, it's good to realize that. So, I would recommend you put each into their own little bucket in terms of breaking it down.

I would even go further and say you should work on understanding each part of MVC first. M is model and ultimately just a plain old class so not much to understand there other than how the View and Controller interact with it.

IMO, Controller is the most important part to understand and part of that is understanding Routes. The controller is in the driver seat (hence the name) and Routes are how you go from URL to the right controller. All else drives off of that.

Understanding Views is primarily understanding plain HTML with some <% %> to include your application bits. In short, if you understand classic ASP, or code-behind-less Web Forms, you would have a good grasp of pretty much all the syntax you need. BUT, you will typically have a lot less code in a View and forget about <asp:xxx runat = "server>.

Once you get a grip on just how the Controller accepts input and then wires up to send the right ActionResult (views being the most common to start), you'll be able to start bringing in the other bits.

I'm confident after a short while, you won't be missing WebForms.

Jim Leonardo
@Jim, i'm not trying to be radical and moved the whole app over to MVC in one fell swoop. Rather i'm trying to learn how to do TDD and introduce more tests to my current webform app :)
melaos
@melaos - that's what we said too. Then once we put in a single chunk of functionality built around MVC, we said we were done building new webforms. We liked it that much. While it seems there's more to understand upfront, there really isn't. And, there seems to be a lot less you need to worry about once you're in flight.
Jim Leonardo
A: 

Phil Haack, who works on Microsoft ASP.NET MVC, has two good blog posts you might find useful:

  1. ASP.NET Supervising Controller (Model View Presenter) From Schematic To Unit Tests to Code
  2. Everything You Wanted To Know About MVC and MVP But Were Afraid To Ask

They won't be completely comprehensive but should serve as good introductions to get you started.

EDIT: Dino Esposito wrote an article on the topic for the September 2010 MSDN magazine: Better Web Forms with the MVP Pattern.

Ahmad Mageed
A: 

Here is a good example where you get a good idea about implementing the MVP in asp.net webforms

http://www.avantprime.com/articles/view-article/2/model-view-presenter-(mvp)-design-pattern-in-asp.net

DaTribe