Test Driven Development with ASP.NET MVC 1.0 Shiju Varghese http://weblogs.asp.net/shijuvarghese
Session Objectives Introduction to ASP.NET MVC Introduction to TDD Demonstrate TDD with ASP.NET MVC
What’s wrong with ASP.NET WebForm ViewState Page life cycle Limited control over rendered HTML Lack of Separation of Concerns (SoC) Untestable
What is MVC A design pattern Acronym for Model View Controller Isolating business logic from UI Layering for UI layer Separation of Concerns (SoC) Separate content from presentation and data-processing (model) from content
What is MVC View is just concerned about presentation logic Models represent the data Controllers just handle application flow You write less code and end up with a more maintainable application.
What is ASP.NET MVC An alternative framework to ASP.NET Web Forms. More control over your HTML A more easily testable framework Simply an option Will not a replacement for Web Form Build on top of ASP.NET Opinionated Framework Community Driven Framework
Goals of ASP.NET MVC Framework Enable clean separation of concerns Each component has one responsibility Single Responsibility Principle (SRP) Highly testable and maintainable application Testable by default (built with TDD in mind) Red/Green/Refactor TDD Enable full control over the rendered HTML Enable clean URLs and HTML SEO and REST friendly URL structures
Goals of ASP.NET MVC Framework Extensible and Pluggable framework. Interface-based architecture Support replacing any component of the system Support third-party view engines such as NVelocity, Brail, NHaml Support user-provided front controller that enable Inversion of Control containers Build on top of ASP.NET Support static and dynamic languages Conventions and Guidance
Test Driven Development Requirement identified Write an automated test Run tests and make sure new one FAILS Write some code Run tests to make sure all PASS Refactor Repeat
Test Driven Development Unit Test Frameworks for .NET: NUnit Visual Studio Test Framework xUnit.NET
Mock Objects In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. Moq Rhino Mocks
Demo
Questions?
Thanks Shiju Varghese E-Mail : [email_address] Blog : http:// weblogs.asp.net/shijuvarghese Twitter : http:// twitter.com/shijucv

TDD with ASP.NET MVC 1.0

  • 1.
    Test Driven Developmentwith ASP.NET MVC 1.0 Shiju Varghese http://weblogs.asp.net/shijuvarghese
  • 2.
    Session Objectives Introductionto ASP.NET MVC Introduction to TDD Demonstrate TDD with ASP.NET MVC
  • 3.
    What’s wrong withASP.NET WebForm ViewState Page life cycle Limited control over rendered HTML Lack of Separation of Concerns (SoC) Untestable
  • 4.
    What is MVCA design pattern Acronym for Model View Controller Isolating business logic from UI Layering for UI layer Separation of Concerns (SoC) Separate content from presentation and data-processing (model) from content
  • 5.
    What is MVCView is just concerned about presentation logic Models represent the data Controllers just handle application flow You write less code and end up with a more maintainable application.
  • 6.
    What is ASP.NETMVC An alternative framework to ASP.NET Web Forms. More control over your HTML A more easily testable framework Simply an option Will not a replacement for Web Form Build on top of ASP.NET Opinionated Framework Community Driven Framework
  • 7.
    Goals of ASP.NETMVC Framework Enable clean separation of concerns Each component has one responsibility Single Responsibility Principle (SRP) Highly testable and maintainable application Testable by default (built with TDD in mind) Red/Green/Refactor TDD Enable full control over the rendered HTML Enable clean URLs and HTML SEO and REST friendly URL structures
  • 8.
    Goals of ASP.NETMVC Framework Extensible and Pluggable framework. Interface-based architecture Support replacing any component of the system Support third-party view engines such as NVelocity, Brail, NHaml Support user-provided front controller that enable Inversion of Control containers Build on top of ASP.NET Support static and dynamic languages Conventions and Guidance
  • 9.
    Test Driven DevelopmentRequirement identified Write an automated test Run tests and make sure new one FAILS Write some code Run tests to make sure all PASS Refactor Repeat
  • 10.
    Test Driven DevelopmentUnit Test Frameworks for .NET: NUnit Visual Studio Test Framework xUnit.NET
  • 11.
    Mock Objects Inobject-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. Moq Rhino Mocks
  • 12.
  • 13.
  • 14.
    Thanks Shiju VargheseE-Mail : [email_address] Blog : http:// weblogs.asp.net/shijuvarghese Twitter : http:// twitter.com/shijucv