Upload
precious-thomas
View
45
Download
0
Tags:
Embed Size (px)
DESCRIPTION
ASP.NET MVC, TDD, and Mock Objects. Josh Gough ATL ALT.NET dotnet.meetup.com/134. Sept 24, 2008: Agenda. 07:00 - 08:00: Dinner, drinks, and open discussion 08:00 - 09:30: Focused discussion: 30 min MVC+TDD+Mock Objects demo; 60 min group discussion on MVC, TDD & Mock Objects. - PowerPoint PPT Presentation
Citation preview
Sept 24, 2008: Agenda
07:00 - 08:00: Dinner, drinks, and open discussion
08:00 - 09:30: Focused discussion: 30 min MVC+TDD+Mock Objects demo;
60 min group discussion on MVC, TDD & Mock Objects
About ATL ALT.NET
We are a community of developers in Atlanta dedicated to helping each other learn and apply the best of .NET technologies.
Based on the “ALT.NET” groups from http://altnetpedia.com
Calendar: http://dotnet.meetup.com/134 Wiki: http://atlalt.net/screwturn/
ASP.NET Model-View-Controller (MVC)
Much like Ruby-on-Rails, other MVC frameworks
From www.asp.net/mvc: Clear separation of concerns (Clean code model,
loose coupling, high cohesion)
Testability - support for Test-Driven Development (And easy to mock dependencies)
Fine-grained control over HTML and JavaScript (works well with async and ajax)
Intuitive URLs (excellent for SEO, strong-naming of URLs)
Test-Driven-Development
From http://en.wikipedia.org/wiki/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
Mock Objects
From http://en.wikipedia.org/wiki/Mock_object
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways.
Good examples of using Mocks:
supplies non-deterministic results (e.g. the current time or temperature);
has states that are difficult to create or reproduce (e.g. a network error);
slow (e.g. a database which would have to be initialized before the test);
does not yet exist or may change behavior; would have to include information and methods
exclusively for testing purposes
Simple Demo: MVC File Processor
Simple, not complete, but demonstrates: NUnit Unit Test Suite Mocked Http File Upload (credit: Scott Hanselman for
this code)
MvcContrib SimplyRestful Routing Extension Some adherence to SOLID design principles Thanks for Chris Rauber, Kevin Skibbe for design ideas here,
and Brian McCafferty for the S#arp architecture http://code.google.com/p/sharp-architecture/
SimplyRestful Routing
Automatically maps controllers to 8 standard “RESTful” routes. Keeps application focused on nouns instead of verbs/actions. Part of MvcContrib.org. Learn more at:
http://abombss.com/blog/2007/12/10/ms-mvc-simply-restful-routing/
public static void RegisterRoutes(RouteCollection routes) {
SimplyRestfulRouteHandler.BuildRoutes(routes);
}