Testing WebForms w/ Model-View-Presenter Erik Peterson What is MVP? A design pattern, similar to Model-ViewController, which allows for separation of concerns Allows for testability via the Presenter MVP vs MVC The MVC way (code-behind): In the beginning, we had code-behind, and it was good Business logic wound up closely tied to the UI The new ASP.NET MVC Framework Gets rid of the .NET heavy-weight webform model MVP vs MVC The MVP way: Model is the same View is the .aspx and code-behind Controller is the Presenter Still have the webform model Model Where the data lives Defines structure and relation of data in your system View Handles the UI Contains the controls (server, HTML, etc) Handles data rendering, layout, etc Implements interface to allow communication with the Presenter Presenter Where the business logic lives Interacts with model to retrieve relevant data Passes data to the view, retrieves necessary info from the view Can use dependency injection for testability MVP From Up High Model Presenter View Our Demo We want to view a list of players on our football team We want to be able to add a player to our team We want to be able to remove a player from our team Where do we begin? Retrieving players, load them to the view Front end vs. Back end And now, to the code! Questions? Blog: http://erikbase.blogspot.com/ Email: cerikpete@gmail.com