testing webforms w/ model-view-presenter erik peterson

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

Upload: chloe-lloyd

Post on 20-Jan-2018

226 views

Category:

Documents


0 download

DESCRIPTION

MVP vs MVC The MVC way (code-behind): In the beginning, we had code-behind, and it was good In the beginning, we had code-behind, and it was good Business logic wound up closely tied to the UI Business logic wound up closely tied to the UI The new ASP.NET MVC Framework Gets rid of the.NET heavy-weight webform model Gets rid of the.NET heavy-weight webform model

TRANSCRIPT

Page 1: Testing WebForms w/ Model-View-Presenter Erik Peterson

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

Erik PetersonErik Peterson

Page 2: Testing WebForms w/ Model-View-Presenter Erik 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 concernsconcernsAllows for testability via the PresenterAllows for testability via the Presenter

Page 3: Testing WebForms w/ Model-View-Presenter Erik Peterson

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

Page 4: Testing WebForms w/ Model-View-Presenter Erik Peterson

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

Page 5: Testing WebForms w/ Model-View-Presenter Erik Peterson

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

Page 6: Testing WebForms w/ Model-View-Presenter Erik Peterson

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

Page 7: Testing WebForms w/ Model-View-Presenter Erik Peterson

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

Page 8: Testing WebForms w/ Model-View-Presenter Erik Peterson

Model Presenter View

MVP From Up HighMVP From Up High

Page 9: Testing WebForms w/ Model-View-Presenter Erik Peterson

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 teamWe want to be able to add a player to our We want to be able to add a player to our teamteamWe want to be able to remove a player We want to be able to remove a player from our teamfrom our team

Page 10: Testing WebForms w/ Model-View-Presenter Erik Peterson

Where do we begin?Where do we begin?

Retrieving players, load them to the viewRetrieving players, load them to the viewFront end vs. Back endFront end vs. Back end

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

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

Questions?Questions?

Blog: Blog: http://erikbase.blogspot.com/Email: Email: [email protected]