Welcome to MSDN Blogs Sign in | Join | Help

Silverlight 2 Beta 1 Controls Available, including Source and Unit Tests

Get Silverlight 2 Beta 1

If you were watching the Keynote from MIX08, you know that Silverlight 2 Beta 1 is now available for download.

The package includes three components:

1) The Silverlight 2 Beta 1 Runtime - installs the basic Silverlight runtime components

2) The Silverlight 2 SDK - includes - installs tools for building Silverlight applications including the controls

3) Microsoft Silverlight Tools Beta 1 for Visual Studio 2008 - installs a project system for Silverlight that works on Visual Studio 2008, including Silverlight XAML Intellisense, Expression Blend interop, and a design-time view of the Silverlight app that you're building.

Get the Source for the Controls

A few months back, we pulled together a team to build out this list of controls.  As part of this effort, we wanted to make sure we delivered something that would really help customers with using the Beta 1 bits. 

So we decided to do to things:

1) Provide source code for the components so users can use it as a sample, or to make changes to the components themselves.

2) Within that project, also ship the Unit Tests that our developers used when writing the components.

You can also download the Silverlight 2 Beta 1 Controls project package now.  The code in this package exactly matches the controls included with the Silverlight 2 Beta 1 SDK download (for example, TextBox, Image, etc. are implemented directly in the runtime).

Simply download the package and unzip it somewhere on your machine using the self-extracting zip.  Once you've done that, launch the project using the "MixControls.sln" solution in VS 2008.

When you launch the solution, you'll see six projects:

Controls - contains basic controls like Button, Checkbox, etc.

Controls.Extended - contains controls like Calendar, Slider, etc.

Controls.Data - contains the DataGrid control

Controls.Test - Unit tests for the Controls project

Controls.Extended.Test - Unit tests for the Controls.Extended project

Controls.Data.Test - Unit tests for the Controls.Data project

Controls Project Test Projects, Controls.Data, Controls.Extended

As expected, all the source code for the controls is in the project.

image

Testing Silverlight Control Code

You can then run the unit tests for any of the projects by launching it's corresponding "Test" project.  Our test harness runs inside of the browser and runs the unit tests.  There are a lot of them -- almost 1500 for the Controls assembly alone! -- and we've gotten very good code coverage.  In the case of the Controls.Test project, for example, we know we're getting over 80% code coverage from our unit tests.  This facility has allowed us to have very few regressions in our control development work, as well as quickly spot any possible issues in the underlying Silverlight runtime when we pick up daily builds. 

Silverlight Control Unit Tests

As you'd expect, the unit tests are basic but provide some functionality that you need for testing in an animated environment like Silverlight.  For example, if the template for a component defines animations, you need to wait for those to run and for the component to be added to the visual tree before checking the state.  You can't do this synchronously, and you can't access the UI thread from another thread.  So we came up with a unique easy to use system for this that handles all that for you, but still lets you write tests that are in one method and are easy to maintain.

Here's an example:

 

image

CreateAsyncTest takes the component, adds it to the Silveright surface, waits for it's Loaded event to fire, then runs the delegate function you've provided (in this case we're using the C# 3.0 Lambda syntax).  It's very clean and simple and allows very rapid writing and execution of tests.

In the controls themselves, you'll also see lots of things to help you write your own control.  In each controls project, you'll find a file called generic.xaml.  This is where you will find the default templates for all of our controls.  You can either customize this in place, or (preferably) use it as a starting point for creating your own templates.

To use these controls in your Silverlight project instead of the default, just add the DLL to your references as you would with any other .NET project and you're set.

More Resources

We're working on getting more sample apps up to help you do usage and templating of controls, but the online docs really are great, including videos and traditional MSDN content.  For example, check out this topic on templating a Button.  Keep an eye on Silverlight.net for more example apps.

I've found the code in these controls invaluable when building Silverlight applications.  I think you will too!

Published Wednesday, March 05, 2008 3:45 PM by sburke
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Silverlight 2: Introducing Microsoft.Silverlight.Testing - Jeff Wilcox

# Silverlight 2: Introducing Microsoft.Silverlight.Testing

As announced during the MIX'08 keynote by Scott Guthrie, not only are we making available the source

Friday, March 07, 2008 8:18 PM by Noticias externas

# More to *just* Silverlight 2 Beta 1 Controls!

Now that I have recovered from the excitement of Las Vegas, I thought I'll sit down and give a run down

Thursday, March 13, 2008 2:34 AM by Kathy Kam

# More to Silverlight 2 Beta 1 Controls than *just* controls!

Now that I have recovered from the excitement of Las Vegas, I thought I'll sit down and give a run

Thursday, March 13, 2008 3:03 AM by Noticias externas

# Silverlight Cream for March 14, 2008 - 2 -- #224

Jeff Paries with OOJS part 2, Chrishayuk with a fix to a listbox stretch problem, Karen Corby gives up

Saturday, March 15, 2008 2:09 AM by Community Blogs

# A Start at Test Driven Development with Silverlight 2

As you likely heard, we have released the source code for all of the Silverlight controls as well as

Tuesday, March 18, 2008 4:14 PM by Blogs

# Silverlight 2.0: Get control's code

Silverlight 2.0: Get control's code

Tuesday, March 18, 2008 4:55 PM by Corrado's BLogs

# A Test Harness!!!!!

   You are THE MAN! Not so much for the control code, which is nice, but for A SILVERLIGHT TEST HARNESS!  Man, I have been dying out here waiting to get back to doing TDD!

   Is there any way you could release the source for the test harness? (Microsoft.Silverlight.Testing + whatever it needs.) That way me, and the god knows how many other TDD addicts can get started building it out.  Nothing complicated, just a simple CodePlex project (or whatever keeps legal happy.)

   Do please ask.  It would make a huge difference for me and an awful lot of others out here.  If you need ammunition, feel free to point that there are no secrets to keep.  I have already been through about half the code with Reflector.  If I have to, I'll go ahead and disassemble it, and start work that way, as there are a couple changes I need immediately.  However, I would FAR rather work with MS's blessing than the other way.  

   In any case, do please ask.  And thanks again for the goodies. Oh, and kudos on some very nice looking code, too.

   If for any reason you need to reach me re the source code thing, you can get me at msblogs@jodysworld.net

   Thanks,

     Jody

Tuesday, March 18, 2008 9:30 PM by Jody.Breshears

# Silverlight 2 beta 1 Controls : i codici sorgenti

Quando sono stati realizzati i cotrolli della beta di Silverlight 2 il team di sviluppo ha deciso di

Wednesday, March 19, 2008 10:22 AM by Il blog del team MSDN Italia

# A Start at Test Driven Development with Silverlight 2

As you likely heard, we have released the source code for all of the Silverlight controls as well as

Friday, March 21, 2008 4:39 PM by Programming

# Silverlight 2, les contrôles et l'écosystème

Incontestablement, les contrôles graphiques sont une des nouveautés de Silverlight 2 qui étaient

Saturday, March 29, 2008 6:28 AM by Christophe Lauer, Blog Edition

# ScottGu Silverlight Reference Page

I'll be using this page to link to Silverlight 2 articles and posts (both ones I write as well ones by

Wednesday, April 02, 2008 1:31 AM by ScottGu's Blog

# Unit Testing with Silverlight

One of the important capabilities we shipped with the Beta1 release of Silverlight 2 was a unit test

Wednesday, April 02, 2008 5:01 AM by ScottGu's Blog

# Unit Testing with Silverlight

One of the important capabilities we shipped with the Beta1 release of Silverlight 2 was a unit test

Wednesday, April 02, 2008 5:15 AM by BusinessRx Reading List

# Unit Testing with Silverlight

One of the important capabilities we shipped with the Beta1 release of Silverlight 2 was a unit test

Wednesday, April 02, 2008 5:57 AM by Mirrored Blogs

# Unit Testing with Silverlight

One of the important capabilities we shipped with the Beta1 release of Silverlight 2 was a unit test

Friday, April 04, 2008 5:10 AM by Programming

# Teste de Unidade com Silverlight

Uma das funcionalidades apresentadas na versão Beta1 do Silverlight 2 é um framework de automação de

Tuesday, April 08, 2008 11:39 PM by Scott Guthrie's Blog in Portuguese

# Silverlight技巧,诀窍,教程和链接

Silverlight技巧,诀窍,教程和链接

【原文地址】SilverlightTips,Tricks,TutorialsandLinksPage

我将使用本页链接到有关Silve...

Wednesday, April 09, 2008 1:00 AM by 大宋提刑官

# Teste de Unidade com Silverlight

Uma das funcionalidades apresentadas na versão Beta1 do Silverlight 2 é um framework de automação de

Wednesday, April 09, 2008 9:40 PM by ScottGu's Blog em Português

# Testy jednostkowe w Silverlight

Jedna z ważniejszych funkcjonalności którą dostarczyliśmy w Silverlight 2 Beta1 są testy jednostkowe

Friday, April 11, 2008 2:27 AM by Scott Guthrie's Blog in Polish

# Fare Unit Test con Silverlight

Fare Unit Test con Silverlight

Sunday, April 13, 2008 6:49 AM by Scott Guthrie Italian WebLog

# Unit testing met Silverlight

Met de Beta1 release van Silverlight 2, lanceerden we een Unit test uitrusting waarmee je unit tests

Monday, April 14, 2008 5:27 AM by Scott Guthrie's Blog in Dutch

# Unit testing met Silverlight

Met de Beta1 release van Silverlight 2, lanceerden we een Unit test uitrusting waarmee je unit tests

Tuesday, April 15, 2008 8:21 AM by Scott Guthrie's Blog in Dutch

# Ever wished for cross-platform Silverlight desktop apps? So has Miguel de Icaza...

From Miguel's de Icaza's web log : Now that controls are part of Silverlight 2.0 and that most of the

Friday, April 18, 2008 8:53 AM by Beyond | IT

# Unit Testing with Silverlight

One of the important capabilities we shipped with the Beta1 release of Silverlight 2 was a unit test

Sunday, June 15, 2008 11:28 AM by Readed By Wrocław NUG members

# Silverlight 文章收集

(以下内容全部整理自博客堂Scottgu博客中文版)Silverlight技巧,诀窍,教程和链接 【原文地址】SilverlightTips,Tricks,...

Monday, July 21, 2008 10:32 PM by 木野狐(Neil Chen)

# 学习如何进行Silverlight 2.0上的单元测试(Unit Testing)

Test support for Silverlight: 1. Silverlight Testing Framework 2.

Thursday, August 21, 2008 11:11 PM by Jack Dong .NET

# Control Freak.

Hmmm...no blogging lately...what has Shawn been up to?  Yes, guilty.  But here's what's been

Wednesday, September 17, 2008 12:40 AM by Shawn Burke's Blog

# Control Freak.

Hmmm...no blogging lately...what has Shawn been up to?  Yes, guilty.  But here's what's

Wednesday, September 17, 2008 3:28 AM by Readed By Wrocław NUG members

# Silverlight技巧,诀窍,教程和链接

Silverlight技巧,诀窍,教程和链接

【原文地址】SilverlightTips,Tricks,TutorialsandLinksPage

我将使用本页链接到有关Silve...

Monday, January 05, 2009 11:09 PM by truejob

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker