testing webforms w/ model-view-presenter

11
Testing WebForms Testing WebForms w/ w/ Model-View- Model-View- Presenter Presenter Erik Peterson Erik Peterson

Upload: tyler-reilly

Post on 30-Dec-2015

27 views

Category:

Documents


4 download

DESCRIPTION

Testing WebForms w/ Model-View-Presenter. Erik Peterson. What is MVP?. A design pattern, similar to Model-View-Controller, which allows for separation of concerns Allows for testability via the Presenter. MVP vs MVC. The MVC way (code-behind): - PowerPoint PPT Presentation

TRANSCRIPT

Testing WebForms w/Testing WebForms w/Model-View-PresenterModel-View-Presenter

Erik PetersonErik Peterson

What is MVP?What is MVP?

A design pattern, similar to Model-View-A design pattern, similar to Model-View-Controller, which allows for separation of Controller, which allows for separation of concernsconcerns

Allows for testability via the PresenterAllows for testability via the Presenter

MVP vs MVCMVP vs MVC

The MVC way (code-behind):The MVC way (code-behind): In the beginning, we had code-behind, and it In the beginning, we had code-behind, and it

was goodwas good Business logic wound up closely tied to the UIBusiness logic wound up closely tied to the UI

The new ASP.NET MVC FrameworkThe new ASP.NET MVC Framework Gets rid of the .NET heavy-weight webform Gets rid of the .NET heavy-weight webform

modelmodel

MVP vs MVCMVP vs MVC

The MVP way:The MVP way: Model is the sameModel is the same View is the .aspx and code-behindView is the .aspx and code-behind Controller is the PresenterController is the Presenter Still have the webform modelStill have the webform model

ModelModel

Where the data livesWhere the data lives Defines structure and relation of data in your Defines structure and relation of data in your

systemsystem

ViewView

Handles the UIHandles the UI Contains the controls (server, HTML, etc)Contains the controls (server, HTML, etc) Handles data rendering, layout, etcHandles data rendering, layout, etc Implements interface to allow communication Implements interface to allow communication

with the Presenterwith the Presenter

PresenterPresenter

Where the business logic livesWhere the business logic lives Interacts with model to retrieve relevant dataInteracts with model to retrieve relevant data Passes data to the view, retrieves necessary Passes data to the view, retrieves necessary

info from the viewinfo from the view Can use dependency injection for testabilityCan use dependency injection for testability

Model Presenter View

MVP From Up HighMVP From Up High

Our DemoOur Demo

We want to view a list of players on our We want to view a list of players on our football teamfootball team

We want to be able to add a player to our We want to be able to add a player to our teamteam

We want to be able to remove a player We want to be able to remove a player from our teamfrom our team

Where do we begin?Where do we begin?

Retrieving players, load them to the viewRetrieving players, load them to the view

Front end vs. Back endFront end vs. Back end

And now, to the code!And now, to the code!

Questions?Questions?

Blog: Blog: http://erikbase.blogspot.com/

Email: Email: [email protected]