Testing a WorkflowService .xamlx file with Visual Studio

One thing I have not tackled until today was how to test a Workflow Service in a .xamlx file.  When I started out this morning working on it I realized that there isn’t a great deal of information about how to do this available anywhere.

Update 7/30/2010 – Download the WF4 Workflow Test Helper library for sample code

Here is what I came up with.  Look at this test and tell me what you think.

using System.Activities;

using System.Activities.Tracking;
using System.ServiceModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WorkflowTestHelper.Tracking;

namespace WorkflowTestHelper.Tests
{
/// <summary>
/// This test demonstrates the WorkflowServiceTestHost class
/// </summary>
[TestClass]
public class WorkflowServiceTestHostTest
{
/// <summary>
/// The endpoint address to be used by the test host
/// </summary>
private readonly EndpointAddress _serviceAddress = new EndpointAddress("net.pipe://localhost/TestService");

/// <summary>
/// Verifies that the WorkflowServiceTestHost hosts a service and that the service receives and sends a reply
/// </summary>
/// <remarks>
/// Be sure to enable deployment - the xamlx file must be deployed
/// </remarks>
[TestMethod]
[DeploymentItem(@"WorkflowTestHelper.Tests.Activities\TestService.xamlx")]
public void ShouldHostService()
{
var trackingProfile =
new TrackingProfile
{
Queries =
{
new ActivityStateQuery
{
ActivityName = "ReceiveRequest",
States = {"Executing"},
},
new ActivityStateQuery
{
ActivityName = "SendResponse",
States = {"Executing"},
},
}
};


using (var host = WorkflowServiceTestHost.Open("TestService.xamlx", _serviceAddress.Uri, trackingProfile))
{
var client = new ServiceClient(new NetNamedPipeBinding(), _serviceAddress);
var response = client.GetData(1);
Assert.AreEqual("1", response);

host.Tracking.Trace();

// Find the tracking records for the ReceiveRequest and SendResponse

// Activity <ReceiveRequest> state is Executing
AssertTracking.ExistsAt(host.Tracking.Records, 0, "ReceiveRequest", ActivityInstanceState.Executing);

// Activity <SendResponse> state is Executing
AssertTracking.ExistsAt(host.Tracking.Records, 1, "SendResponse", ActivityInstanceState.Executing);
}
}
}
}

-Updated on 7/30/2010- Windows Azure AppFabric LABS August Release, Breaking Changes Announcement and Scheduled Maintenance

The Windows Azure AppFabric LABS August release is scheduled for August 5, 2010 (Thursday).  Users will have NO access to the AppFabric LABS portal and services during the scheduled maintenance down time.  

 

When:

 

    START: August 5, 2010, 10am PST

    END:  August 5, 2010, 6pm PST

 

Impact Alert:

    LABS AppFabric Service Bus, Access Control and portal will be unavailable during this period. Additional impacts are described below.

 

Action Required:

 

Existing accounts and Service Namespaces will be available after the services are deployed.

 

However, ACS Rules, Issuers, Scopes, and Token Policies will NOT be persisted and restored after the maintenance. Users will need to back up their data if they wish to restore them after the Windows Azure AppFabric LABS August Release.

 

Also note that the Service Bus Multicast with Message Buffers features, which have been available in LABS since March 2010, will be temporarily removed from the LABS environment. The team is working on an alternative approaches to these features.

 

Thanks for working in LABS and giving us valuable feedback.  Once the update becomes available, we’ll post the details via this blog. 

Stay tuned for the upcoming LABS release!

 

The Windows Azure AppFabric Team

Visual Studio 2010 Keyboard Shortcuts

Visual Studio 2010 Keyboard Shortcuts

Earlier this week the Visual Studio team released updated VS 2010 Keyboard Shortcut Posters.  These posters are print-ready documents (that now support standard paper sizes), and provide nice “cheat sheet” tables that can help you quickly lookup (and eventually memorize) common keystroke commands within Visual Studio.

image

This week’s updated posters incorporate a number of improvements:

  • Letter-sized (8.5”x11”) print ready versions are now available
  • A4-sized (210x297mm) print ready versions are now available
  • The goofy people pictures on them are gone (thank goodness)

The posters are in PDF format – enabling you to easily download and print them using whichever paper size is in your printer.

Download the Posters

You can download the VS 2010 Keybinding posters in PDF format here.

Posters are available for each language.  Simply look for the download that corresponds to your language preference (note: CSharp = C#, VB = VB, FSharp = F#, CPP = C++). 

Hope this helps,

Scott

P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu

SharePoint 2010: SPMetal.exe and system fields namely ContentType

Olaf and I were cracking away on some SharePoint 2010 work which we thought should
be simplepoint SPMetal to the site and start LINQ-ing to our hearts content..

with the one exception that we couldn’t select items from a list based on their Content
Type
.

By default SPMetal.exe doesn’t include these ’system’ fields (apart
from ID + Title – go figure) and the secret is to use an Override file.

The good oil is:http://msdn.microsoft.com/en-us/library/ee535056.aspx

(Here’s a good article on how .NET Types are mapped to SharePoint – http://msdn.microsoft.com/en-us/library/ee536245.aspx)

The simple override/parameters file:

<Web AccessModifier="Internal" xmlns="http://schemas.microsoft.com/SharePoint/2009/spmetal">

  <ContentType Name="Item" Class="Item">
    <Column Name="ContentType" Member="ContentType" />
  
  </ContentType>
 
</Web>

 

The SPMetal Command Line

The VS.NET Code

 static void Main(string[]
args)
        {
            using (BreezeDataContext dc = new BreezeDataContext("http://breezelocal"))
            {
                var myitems = from i in dc.GetList<ContentListTraining>("My Content List")
                              where i.ContentType == "Training"
                              select i;
                var courses = myitems.ToList<ContentListTraining>();

                Console.WriteLine("There are {0} items",courses[0].Title);
                   
            }

            Console.ReadLine();
        }