Monday, November 24, 2008

Daily Links 24/11/2008

Introducing TransitionContentControl
"write a very simple contentControl, that allows you to transition your old content with your new content"
Cool :)

Dynamically Loading an assembly at Runtime and calling its methods
Check out the comment as well. Handy for getting a start to a plug-in application architecture

Producing readable log4net output

Visual SVN 1.6 released
If you're looking for a free SVN IDE plugin for VS, then head on over to Ankh - muchly improved over the last year or so.

Practicing Agility in Application Architecture
"Microsoft has published a How-To Design Using Agile Architecture guide under patterns & practices providing detailed guidelines to follow when architecting an application, the Agile way."

WCF REST Starter Kit Hands On Labs
REST Services seems to be making a bit of a revival - here's some help to get started.

Setting up Subversion on Windows Home Server
Simple as 1-2-3

Friday, November 21, 2008

Daily Links - 21/11/2007

What Gives? Microsofts Code Generation Tool
T4: Free code generation tool from Microsoft

New Silverlight Application Checklist
Things to do when you first create a Silverlight application

Specifying timeout duration for WCF services

Securing your WCF Services for your Silverlight Application

How to create a Visual WebGui Silverlight application
VWG is something I've kept my eye on for a while now, and it is very interesting what they are doing to increase development productivity, as well as offer an innovative server-side "ajaxian" architecture, which address concerns such as efficient data transfer and security.

How to start with Scrum

The Decline and Fall of Agile
Why is agile getting a bad name? Read on...

Nine Things Developers Want More Than Money

Tuesday, November 18, 2008

Daily Links 18/11/2008

Use styles for an editable silverlight combobox

AutoCompleteBox control / Worker Threads

Silverlight Glass Button

Combining different seperated presentation patterns
I think in "real-world" development this is a necessity.

Update on Silverlight 2 - and a glimpse of Silverlight 3

NUnitLite
NUnit for Compact Framework, Mono, embedded projects etc.
Was looking for something to run NUnit tests on my compact framework stuff, and this seemed to be the best solution available.

JetBrains Has Released IntelliJ IDEA 8
"Includes SQL, new refactorings, inspections, UML diagrams, JBoss Seam, better performance and more."
I work mostly in the .NET space these days, but my brief stint into the Java world taught me there is no better IDE for Java than IntelliJ

Wednesday, November 5, 2008

Daily Links 05/11/2008

Silverlight Toolkit released on Codeplex
"collection of Silverlight controls, components and utilities made available outside the normal Silverlight release cycle"

Silverlight Tools RTW released
was wondering why the previous release was labelled RC1 :)

Building a Silverlight Line-Of-Business Application - Part 2
Covers DataGrid functionality - comparing the silverlight datagrid to the very capable open-source grid from DevExpress

Silverlight and IIS Smooth Streaming
All I can say is....wow :)

Silverlight and WPF Tookit
woohoo! WPF finally gets VisualStateManager

DatePicker & Calendar released for WPF

Compiled LinQ Queries
Speed up LinQ to SQL performance

Linq to SQL: Delete an entity using Primary Key only

New IT Architecture resource

Premier Survey
Conduct online surveys for free :)

40 Beautiful Free Icon Sets

Tuesday, October 28, 2008

Daily Links 28/10/2008

Creating Drop Shadows in Silverlight Using Nested Borders

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:

image

...and here is how the svcUtil generates the proxy on the client in order to call the service methods:

Service implementation:
image

Service interface:
image

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:

  1. Add a new class file on the Silverlight client
  2. 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.
  3. Define a new interface - using the example, mine would be:image  
  4. Extend the existing interface if necessary (in the example interface derives from FooBarService interface.)
  5. Include the public "[XYZ]Asynch" methods that you would like to mock into the interface as well as the return event definitions.
  6. Apply the interface to the service implementation class - luckily the class is declared as partial in the proxy, so this is quite easy: image

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:

image

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