Tuesday, October 28, 2008
Daily Links 28/10/2008
Loading assemblies dynamically in silverlight
Using Isolated Storage in Silverlight
Silverlight Tip of the Day #65 - Adding a Mouse Wheel Event Listener to your Controls
Silverlight 2 and Localisation/Globalisation
seems by default silverlight gets culture settings from the OS, and not from the browser as I had expected
Neptune SMTP Development Server
"a SMTP server that did not relay the message and allowed me to query for messages and their content"
SVN-Monitor is out!
Free full-featured user-front-end to SubVersion for Windows.
Building an Error Icon in WPF
Singletonitis
Microsoft Pre-release Software Visual Studio 2010 and .NET Framework 4.0 Community Technology Preview (CTP)
Mocking out WCF Services in Silverlight 2.0 for Unit Testing
Brief Background:
When consuming WCF Services in Silverlight, proxy classes are generated to make using the service a lot more simple. These service proxy classes offer a simple implementation of the asynchronous service methods (synchronous service calls are not supported in silverlight).
If you're following TDD, then you want to test your client-side silverlight C# code in some sort of testing framework, and if you're writing proper unit tests, you are going to mock out the boundaries to the logic in the code (Xaml views and service references).
Problem:
Although interfaces are also generated for the service proxy classes, for some reason Microsoft left out the simple public methods in the interface definition - which 9/10 times are the only methods the developer is going to use! - go figure?!
Here is a simple service definition on the server:
...and here is how the svcUtil generates the proxy on the client in order to call the service methods:
Notice that the simple "DoFooAsynch" methods have not been exposed on the interface!
Solution:
Briefly, the solution is to include the simple asynchronous helper methods in an extension of the interfaces already defined.
Do the following:
- Add a new class file on the Silverlight client
- Change the namespace to be the same as the namespace defined in the reference.cs file (where the proxy classes have be generated) - make sure to click the "Show All Files" on top of the solution explorer to find it.
- Define a new interface - using the example, mine would be:
- Extend the existing interface if necessary (in the example interface derives from FooBarService interface.)
- Include the public "[XYZ]Asynch" methods that you would like to mock into the interface as well as the return event definitions.
- Apply the interface to the service implementation class - luckily the class is declared as partial in the proxy, so this is quite easy:
Now in the code, the logic to be tested should have a reference to this newly created interface, and not the actual service itself. Use either the factory pattern or dependency injection (both of which should be familiar to you if you're doing TDD) to inject the service implementation at runtime.
But what about injecting the mock during testing? Here's a pattern which I've found helpful:
When testing the logic code, I inject my mock service which implements the service interface into the constructor of the logic class, and in production, I let the ServiceLocator resolve the service implementation in the default constructor.
Using this methodology, you can effectively remove the service dependency in your unit tests :) (remember to call the service implementation in your integration tests!)
Happy Testing...
Jax
Tuesday, October 21, 2008
Daily Links 21/10/2008
Stealth Paging : DataGrid
ComboBox in DataGrid
Building Business Application with Silverlight 2 (Beta 2)
Desktop Applications with Silverlight
Defining dynamic DataGridColumnTemplate columns in a datagrid
28 Free File Storage Hosting Websites
T4 (Text Template Transformation Toolkit) Code Generation - Best Kept Visual Studio Secret
Create Portable Applications With Ease
"developers can create a portable, self-contained application that relies on the virtual registry and file system to run on the machine"
How To Localize Your Application Using String Tables
Tuesday, October 14, 2008
Daily Links 14/10/2008
Silverlight is finally RTW!
Silverlight 2.0: A Double Click Manager
Silverlight doesn't inherently support the double-click event on it's controls - this is a nice work-around
Announcing the Test Driven Development Productivity Plugin for Resharper
Karvonite - Agile Persistence Framework
"non-invasive to your code and requires no interfaces or base classes for saving objects" - sounds promising
R# productivity & quality plugins
Agent Smith & Agent Johnson
Object Oriented Architecture As It Should Have Been - Agile Architecture
.NET 3.5. SP1 best practices - When to use the ASP.NET MVC Framework
Wednesday, October 8, 2008
Daily Links 08/10/2008
Common Service Locator Library - IServiceLocator Interface Abstracting IoC Containers
Faults and Exceptions when using Web Services in Silverlight 2
Dave's Glossy Controls for Silverlight 2 released
"set of easily customisable control templates"
XAML Power Toys 3.1.0.2 Has Silverlight 2 Support!
Free property grid control for WinForms Development
ala property grid in visual studio
An initialization pattern to avoid problems calling virtual method in constructor
Installing VisaulSVN Subversion
A few thoughts on the role of software architects
Master Complex Builds with MSBuild
MSBuild Extension Pack
"...provides a collection of over 170 MSBuild tasks designed for the .net 3.5 Framework"
Mono 2.0 is out!
Write .NET code for OS other than Windows
Friday, October 3, 2008
Daily Links 03/10/2008
Faults and Exceptions when using Web Services in Silverlight 2
Silverlight Page Turner
including source code
Overview of CSLA .NET 3.6 for Windows and Silverlight
"CSLA .NET version 3.6 is a framework for creating business applications using object-oriented design concepts, in a distributed computing environment."
Silverlight multi-file upload controls and patterns
What's new in Silverlight 2 RC0
XAML Power Toys 3.0.0 Released - Code Name: Refactored
Silverlight support round the corner :)
Adding social bookmarking links to blogger
Development Tools I Use & Recommend