tdd with asp.net mvc 1.0

14

Click here to load reader

Upload: shiju-varghese

Post on 17-May-2015

1.343 views

Category:

Technology


1 download

DESCRIPTION

TDD with ASP.NET MVC 1.0

TRANSCRIPT

Page 1: TDD with ASP.NET MVC 1.0

Shiju VargheseShiju Varghese

http://weblogs.asp.net/shijuvarghesehttp://weblogs.asp.net/shijuvarghese

Test Driven Development Test Driven Development with ASP.NET MVC 1.0with ASP.NET MVC 1.0

Page 2: TDD with ASP.NET MVC 1.0

Session ObjectivesSession Objectives

Introduction to ASP.NET MVCIntroduction to ASP.NET MVC Introduction to TDDIntroduction to TDD Demonstrate TDD with ASP.NET MVCDemonstrate TDD with ASP.NET MVC

Page 3: TDD with ASP.NET MVC 1.0

What’s wrong with ASP.NET What’s wrong with ASP.NET WebFormWebForm

ViewStateViewStatePage life cyclePage life cycleLimited control over rendered HTMLLimited control over rendered HTMLLack of Separation of Concerns (SoC)Lack of Separation of Concerns (SoC)UntestableUntestable

Page 4: TDD with ASP.NET MVC 1.0

What is MVCWhat is MVC

A design patternA design pattern Acronym for Model View ControllerAcronym for Model View Controller Isolating business logic from UIIsolating business logic from UI Layering for UI layerLayering for UI layer Separation of Concerns (SoC)Separation of Concerns (SoC)

Separate content from presentation and data-Separate content from presentation and data-processing (model) from contentprocessing (model) from content

Page 5: TDD with ASP.NET MVC 1.0

What is MVCWhat is MVC

View is just concerned about View is just concerned about presentation logicpresentation logic

Models represent the dataModels represent the data Controllers just handle Controllers just handle

application flow application flow You write less code and end You write less code and end

up with a more maintainable up with a more maintainable application.application.

Page 6: TDD with ASP.NET MVC 1.0

What is ASP.NET MVCWhat is ASP.NET MVC An alternative framework to ASP.NET Web An alternative framework to ASP.NET Web

Forms.Forms. More control over your HTMLMore control over your HTML A more easily testable frameworkA more easily testable framework Simply an optionSimply an option

Will not a replacement for Web FormWill not a replacement for Web Form Build on top of ASP.NETBuild on top of ASP.NET

Opinionated FrameworkOpinionated Framework Community Driven FrameworkCommunity Driven Framework

Page 7: TDD with ASP.NET MVC 1.0

Goals of ASP.NET MVC Goals of ASP.NET MVC FrameworkFramework

Enable clean separation of concernsEnable clean separation of concerns Each component has one responsibilityEach component has one responsibility

Single Responsibility Principle (SRP)Single Responsibility Principle (SRP) Highly testable and maintainable applicationHighly testable and maintainable application

Testable by default (built with TDD in mind)Testable by default (built with TDD in mind) Red/Green/Refactor TDD Red/Green/Refactor TDD

Enable full control over the rendered HTMLEnable full control over the rendered HTML Enable clean URLs and HTMLEnable clean URLs and HTML

SEO and REST friendly URL structuresSEO and REST friendly URL structures

Page 8: TDD with ASP.NET MVC 1.0

Goals of ASP.NET MVC Goals of ASP.NET MVC FrameworkFramework

Extensible and Pluggable framework.Extensible and Pluggable framework. Interface-based architectureInterface-based architectureSupport replacing any component of the systemSupport replacing any component of the systemSupport third-party view engines such as Support third-party view engines such as

NVelocity, Brail, NHaml NVelocity, Brail, NHaml Support user-provided front controller that Support user-provided front controller that

enable Inversion of Control containersenable Inversion of Control containers Build on top of ASP.NETBuild on top of ASP.NET Support static and dynamic languagesSupport static and dynamic languages Conventions and GuidanceConventions and Guidance

Page 9: TDD with ASP.NET MVC 1.0

Test Driven DevelopmentTest Driven Development

Requirement identifiedRequirement identifiedWrite an automated testWrite an automated testRun tests and make sure new one FAILSRun tests and make sure new one FAILSWrite some codeWrite some codeRun tests to make sure all PASSRun tests to make sure all PASSRefactorRefactorRepeatRepeat

Page 10: TDD with ASP.NET MVC 1.0

Test Driven DevelopmentTest Driven Development

Unit Test Frameworks for .NET:NUnitVisual Studio Test FrameworkxUnit.NET

Page 11: TDD with ASP.NET MVC 1.0

Mock ObjectsMock Objects

o In object-oriented programming, mock In object-oriented programming, mock objects are simulated objects that mimic objects are simulated objects that mimic the behavior of real objects in controlled the behavior of real objects in controlled ways.ways.MoqMoqRhino MocksRhino Mocks

Page 12: TDD with ASP.NET MVC 1.0

DemoDemo

Page 13: TDD with ASP.NET MVC 1.0

Questions?Questions?

Page 14: TDD with ASP.NET MVC 1.0

ThanksThanks

Shiju VargheseShiju Varghese

E-Mail : E-Mail : [email protected]@live.com

Blog : Blog : http://http://weblogs.asp.net/shijuvargheseweblogs.asp.net/shijuvarghese

Twitter : Twitter : http://http://twitter.com/shijucvtwitter.com/shijucv