Unit Testing, Presentation Model and the HTML Bridge at CodeCamp NZ
September 1st 2008
Yesterday I gave a Silverlight presentation and CodeCamp Auckland. The presentation was focusing on how to apply dependency injection in Silverlight using Ninject, unit testing and the presentation model pattern. Towards the end I threw in a little HTML-bridge fun, and demonstrated the webcam in Silverlight implementation I did some time back. Rob Fonesca-Ensor had done a great job of introducing TDD, IoC and DI on an earlier presentation, so I could focus on how to apply the techniques in a Silverlight context. Ivan Towlson did a presentation on “thinking in WPF” and did a good job of explaining why you need to take a different approach to building WPF application than what you’re used to from traditional Windows Forms. I tried to tie my YouCard demo back to some of the ideas introduced by Ivan, and hope these three sessions together gave people who want to start building Silverlight and WPF applications a good starting point.
Owen Evans and Scott Hanselman had the ASP.NET part of the CodeCamp covered. Owen talked about ASP.NET MVC while Scott did a session on ASP.NET Dynamic Data. There more I see of Dynamic Data, the more intrigued I am by it. I think people easily dismiss Dynamic Data as just scaffolding and code generation. Scott made a point of this, and really went through the details of how a Dynamic Data application is built up. No magic or code generation, all meta-programming.
All in all this was an excellent CodeCamp, the second one I’ve attended. I presented at the Australian CodeCamp back in April. Kirk Jackson and gang did a great job of organizing the CodeCamp. I think we need to get a CodeCamp started back in Norway as well.
I’ve put together some references and links if you want to dive deeper in some of the topics I covered in my talk, as well as download links to the demo applications.
Unit Testing in Silverlight
- Unit Testing with Silverlight 2 by Jeff Wilcox
Jeff is the primary developer on the Silverlight testing framework, and this is probably the best introduction to Silverlight Unit Testing. - Unit testing templates for Microsoft Silverlight 2 Beta 2
To make things easier Jeff has prepared a Visual Studio template to set up Silverlight Unit Testing. - What’s in the pipeline for Silverlight Test Developers
Jeff hints about what might come in the next version of the Silverlight testing framework. - Unit Testing Asynchronous Code in Silverlight
This is a post I did back in June describing how to use the Asynchronous attribute, and how to write asynchronous tests in Silverlight. - Silverlight NUnit Projects
Jamie Cansdale explains how to use NUnit to do Silverlight testing. The benefit of using NUnit is that you can run your tests outside the browser, execute the tests from TestDriven.Net, and even get code coverage. For integration testing (network, browser integration) you still need to use the Silverlight Testing Framework from Microsoft. - White – Windows Application Automation
Open source framework to automate and test Win32, Windows Forms, WPF and Java. Since Silverlight supports the same UI Automation API as WPF you should be able to use this framework to test Silverlight applications as well.
Presentation Model / View Model
- ViewModel Pattern in Silverlight using Behaviors
Nikhil Kothari introduces the ViewModel pattern in a Silverlight context. He also shows how to add declarative behaviors to Silverlight controls to get decoupled events. - ViewModel Pattern extended with the Dynamic Language Runtime
In this post Nikhil extends his ViewModel example and use the dynamic language runtime to get an even more elegant way of adding behaviors to Silverlight controls. - Presentation Model
Fowlers essay describing the Presentation Model pattern. In essence this is the same pattern as the Model-View-ViewModel pattern, but not in a Silverlight/WPF specific context. - YouCard Re-visited: Implementing the ViewModel pattern
In this post I describe how I refactored the YouCard application to use the ViewModel pattern. - PIXEL8 Pod Cast – John Gossman Architects WPF
In this post cast John discusses the value of the Model-View-ViewModel design pattern, one of the patterns used when designing Expression Blend.
Dependency Injection and Ninject
- Ninject: Lightning-fast dependency injection for .NET
One of the cool things about Ninject is the great landing page for the project. It gives you easy access to download links, tutorials, the coding dojo and the discussion board. It’s a really easy framework to get started with. - List of .NET Dependency Injection Containers (IoC)
Scott Hanselman has assembled a list of .NET IoC containers, and gives a brief description of each of them. - YouCard Re-visited: Implementing Dependency Injection in Silverlight
In this post I describe how I added dependency injection to the YouCard application using Ninject.
HTML Bridge
- Webcam in Silverlight 2 – MacGyver Style
This is the initial post I did describing how to get basic webcam support in Silverlight using the HTML Bridge and Flash interop. - Webcam in Silverlight 2 – Sliding Puzzle Game
Follow-up post adding a new sample application – The Sliding Puzzle Game. - Silverlight and Flash Interoperability using the HTML Bridge and ExternalInterface API
An article I wrote for SilverlightShow.net describing how to get Silverlight and Flash applications talking to each other. - Interaction between HTML and Managed Code
Microsoft Quick Start introducing you to the HTML Bridge. - Real-time data in HTML with Silverlight
In this post Marc Holmes shows how to get real-time data in HTML using Silverlight Sockets and the HTML Bridge. - Back and Forward navigation in Silverlight
Michael S. Scherotter shows how to get back and forward navigation and bookmarks in a Silverlight application.
Demos
You can download both the Web Cam and YouCard demo applications from my Windows Live Sky Drive. I’ve also uploaded the demos so that you can play the Sliding Puzzle Game or check out your friends using YouCard. You can even run the unit tests directly from your browser! Hope you found my presentation useful. Feel free to post any questions, comments or feedback.