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

Testing WebForms w/ Model-View-Presenter

Dec 30, 2015

Download

Documents

Tyler Reilly

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
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Testing  WebForms  w/ Model-View-Presenter

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

Erik PetersonErik Peterson

Page 2: Testing  WebForms  w/ Model-View-Presenter

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

Page 3: Testing  WebForms  w/ Model-View-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

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

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

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

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

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

Model Presenter View

MVP From Up HighMVP From Up High

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

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

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

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!

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

Questions?Questions?

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

Email: Email: [email protected]