Blatant ad for upcoming courses

Blatant ad for upcoming courses

As a break from your normally scheduled technical content (or I guess abnormally scheduled
considering my blogging habits lately), here are some classes I am teaching in the
near future.

#1 – If you are in So Cal or you just feel like getting away from whatever cold, snowy
local you are living in – I’ll be teaching BizTalk Server 2006 R2 in Irvine, CA – https://www.pluralsight.com/registration/register.aspx?offeringid=267.

#2 – Again  in (sunny) Irvine – Aaron
Skonnard and I will be doing a WCF/WF “Double-Feature” https://www.pluralsight.com/registration/register.aspx?offeringid=268 
If you are interested in knowing all the new stuff in .NET 3.5 – we’ll be covering
that as well.

#3 – NY in August?  Well – can’t really say come for the weather – but again
I’ll be doing our BizTalk Server 2006 R2 class on August 4th-8th in NY.  https://www.pluralsight.com/registration/register.aspx?offeringid=291 
come for the training – stay for the food? (I guess I should give up my hope of being
an adversiting guru).

Thanks for listening.  Technical content coming RSN.



Check out my BizTalk
R2 Training.

Unit Testing with Silverlight

Unit Testing with Silverlight

One of the important capabilities we shipped with the Beta1 release of Silverlight 2 was a unit test harness that enables you to perform both API-level and UI-level unit testing.  This testing harness is cross browser and cross platform, and can be used to quickly run and verify automated unit tests:

In addition to shipping this unit test harness for Silverlight, we also shipped the source to ~2,000 unit tests built with it that provide automated coverage for the Silverlight control source that we also shipped under a permissive license (you can take the control source, modify it, run the unit tests to verify the behavior, then re-ship the controls however you want).

Learning How to Unit Test Silverlight

Jeff Wilcox (who developed the Silverlight unit test framework and harness) has a great blog post that talks about how to add a Silverlight Unit Test project to a solution here. You can download the chat application that he shows testing from this expression blend blog post tutorial I did last month.  You can also watch this cool video post that Jeff created where he walks through the unit test framework and test cases we’ve shipped.

As Jeff shows in his post, you can now add a "Silverlight Test Project" to your Visual Studio solution which encapsulates unit tests for an application you are working on:

You can then add unit test classes to the test project that test APIs or simulate UI action within the Silverlight controls (simulate button clicks, etc).

You can then run the test project and execute the tests within it to verify and report their status.

Jeff’s test framework automatically provides a browser based test harness and reporting system (which means you can run it on any browser/OS combination that Silverlight runs on):

Jeff’s test framework supports quickly re-setting controls after each test (and avoids needing to re-launch a new browser instance for each test cases – which makes it really fast).

You can quickly rip through hundreds or thousands of automated tests in seconds:

Green results mean the tests passed.  Red results flag that a test case failed and log the assertion failure and/or runtime exceptions that occurred.

Summary

If you’ve ever struggled to try and come up with a strategy for doing automated unit testing or TDD with AJAX applications, I think you’ll find Silverlight provides some much nicer test options.  Using Visual Studio you can also separate your tests into a separate project in your solution, and you do not need to embed the tests within your Silverlight application in order for them to run.

In addition to supporting the above unit test harness and framework, we are also going to support UI automation APIs with the final release of Silverlight 2.  These will enable accessibility scenarios (allowing screen readers to work with Silverlight and enable Section 508 compliance of Silverlight applications).  These UI automation APIs will also enable UI testing scenarios where you can build end to end browser UI automation that simulates real mouse and keyboard interactions and enables automated end to end experience testing.  The combination should enable you to build much more solid and maintainable RIA solutions.

Hope this helps,

Scott

P.S. For more tutorial posts and links on Silverlight 2, check out my new "Silverlight Tips, Tricks, Tutorials and Links" page.

Unit Testing with Silverlight

Unit Testing with Silverlight

One of the important capabilities we shipped with the Beta1 release of Silverlight 2 was a unit test harness that enables you to perform both API-level and UI-level unit testing.  This testing harness is cross browser and cross platform, and can be used to quickly run and verify automated unit tests:

In addition to shipping this unit test harness for Silverlight, we also shipped the source to ~2,000 unit tests built with it that provide automated coverage for the Silverlight control source that we also shipped under a permissive license (you can take the control source, modify it, run the unit tests to verify the behavior, then re-ship the controls however you want).

Learning How to Unit Test Silverlight

Jeff Wilcox (who developed the Silverlight unit test framework and harness) has a great blog post that talks about how to add a Silverlight Unit Test project to a solution here. You can download the chat application that he shows testing from this expression blend blog post tutorial I did last month.  You can also watch this cool video post that Jeff created where he walks through the unit test framework and test cases we’ve shipped.

As Jeff shows in his post, you can now add a "Silverlight Test Project" to your Visual Studio solution which encapsulates unit tests for an application you are working on:

You can then add unit test classes to the test project that test APIs or simulate UI action within the Silverlight controls (simulate button clicks, etc).

You can then run the test project and execute the tests within it to verify and report their status.

Jeff’s test framework automatically provides a browser based test harness and reporting system (which means you can run it on any browser/OS combination that Silverlight runs on):

Jeff’s test framework supports quickly re-setting controls after each test (and avoids needing to re-launch a new browser instance for each test cases – which makes it really fast).

You can quickly rip through hundreds or thousands of automated tests in seconds:

Green results mean the tests passed.  Red results flag that a test case failed and log the assertion failure and/or runtime exceptions that occurred.

Summary

If you’ve ever struggled to try and come up with a strategy for doing automated unit testing or TDD with AJAX applications, I think you’ll find Silverlight provides some much nicer test options.  Using Visual Studio you can also separate your tests into a separate project in your solution, and you do not need to embed the tests within your Silverlight application in order for them to run.

In addition to supporting the above unit test harness and framework, we are also going to support UI automation APIs with the final release of Silverlight 2.  These will enable accessibility scenarios (allowing screen readers to work with Silverlight and enable Section 508 compliance of Silverlight applications).  These UI automation APIs will also enable UI testing scenarios where you can build end to end browser UI automation that simulates real mouse and keyboard interactions and enables automated end to end experience testing.  The combination should enable you to build much more solid and maintainable RIA solutions.

Hope this helps,

Scott

P.S. For more tutorial posts and links on Silverlight 2, check out my new "Silverlight Tips, Tricks, Tutorials and Links" page.

WCF: Deserialization error, the response elements disappeared.

Deserialization error, the response elements disappeared. Namespace in Wsdl is not conforming to the namespace in Response message
I generated client for the Web-service and made a request.
The response on the service side had the data inside, the notification element.
The problem was on the client side where the notification element disappeared.
I used the SoapUI utility to test the service. The SoapUI response had the right notification element! But my client got any notification element.
I created different type of clients in VS2005, VS2008, by SvcUtil.exe, as Service-reference (as the WCF-client), and Web-reference (as Asmx client). I generated the proxy with the Software Factory. The result was the same, any notification element! And the SoapUI had get the right response with right notification element
Response in the SoapUI was:
<soapenv:Body>
<ns:removeNotificationByEmailIDResponse xmlns:ns=”http://service.MyService“>
<ns:return type=”projectnamespace.Notifications”>
<ns:notification type=”projectnamespace.Notification”>
<ns:msgID>159</ns:msgID>
</ns:notification>
</ns:return>
</ns:removeNotificationByEmailIDResponse>
</soapenv:Body>
Responses in my clients were:
<soapenv:Body>
<ns:removeNotificationByEmailIDResponse xmlns:ns=”http://service.MyService“>
<ns:return type=”projectnamespace.Notifications”>
</ns:return>
</ns:removeNotificationByEmailIDResponse>
</soapenv:Body>
At last I started to compare Responses and the Wsdl, and I had found source of this problem.
In short word, Wsdl did not conform to Response messages.
For instance, Response message was:
<soapenv:Body>
<ns:removeNotificationByEmailIDResponse xmlns:ns=”http://service.MyService“>
<ns:return type=”projectnamespace.Notifications”>
<ns:notification type=”projectnamespace.Notification”>
<ns:msgID>159</ns:msgID>
</ns:notification>
</ns:return>
</ns:removeNotificationByEmailIDResponse>
</soapenv:Body>
And the Wsdl was:
<wsdl:types>
<xs:schema xmlns:ax22=”http://vo.com/xsd attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://vo.com/xsd“>
<xs:complexType name=”Notification”>
<xs:sequence>
<xs:element minOccurs=”0″ name=”msgID” nillable=”true” type=”xs:long” />
</xs:sequence>
</xs:complexType>
<xs:complexType name=”Notifications”>
<xs:sequence>
<xs:element minOccurs=”0″ maxOccurs=”unbounded” name=”notification” nillable=”true” type=”ax22:Notification” />
</xs:sequence>
</xs:complexType>
</xs:schema>
This Wsdl generates the proxy like:
[System.Runtime.Serialization.CollectionDataContractAttribute(Name = “Notifications”, Namespace = “http://vo.com/xsd, ItemName = “notification”)]
[System.SerializableAttribute()]
public class Notifications : System.Collections.Generic.List<vo.notification.clearmedia.com.xsd.Notification>
{
}
[System.Runtime.Serialization.DataContractAttribute(Name = “Notification”, Namespace = “http://vo.com/xsd”)]
[System.SerializableAttribute()]
public partial class Notification : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
{
private string msgIDField;
I’ve marked the errors. In Wsdl classes Notification and Notifications had Namespace = “http://vo.com/xsdbut in response messages they had namespaces xmlns:ns=”http://service.MyService“.
I’ had change the first namespace to the second one in the proxy code and the client started working well.
SoapUI returns the response but it doesn’t care about processing the response message, it just shows response.
The service was created by Axis2 tool and service developers told me that they could not change this error. When I request the Wsdl, it generates automatically somewhere inside tool and the error could not be fixed easily.
Conclusion: If the response is compound from the elements with several namespaces and some elements do not passed the proxy, check if these elements in the response message and in the Wsdl have the same namespaces. If namespace in Wsdl is not conforming to the namespace in Response message the proxy does not serialize the elements. It does it silently without errors!

Article Series on BizTalk and WCF: Part VI, Publishing Advanced Services Patterns

I just posted another article for TopXML.com as part of my series on BizTalk + WCF.   This post digs into exposing WCF services out of BizTalk that utilize security features, MTOM attachments, and transactions.
Topics include: message-based security, transport security, custom role based authorization, MTOM attachments, and how to send messages to BizTalk as part of […]