Why Updated Platform Support Matters

By Nick Hauenstein

This post is the fifth in a weekly series intended to briefly spotlight those things that you need to know about new features in BizTalk Server 2013.

Each new version of BizTalk brings with it support for the latest Microsoft Operating System, Database Engine, and Integrated Development Environment. It is listed as a new feature each time, and many tend to skip over that feature on the new features list. However, this is actually very powerful – especially when considering the change over time in those underlying platforms.

In this post, I’m going to examine how the Microsoft Fakes framework (found in Visual Studio 2012.2 Premium) can enable interesting testing scenarios for code that wasn’t built specifically for test. In the process, I’m also going to be using the Winterdom  PipelineTesting library – which is easily upgraded to 2013 with some re-referencing of BizTalk assemblies.

Testing the Un-Testable

The Microsoft Fakes framework (available in Visual Studio 2012 Ultimate, or 2012.2 Premium edition and above) provides the ability to create both stubs and shims of any .NET interface or class respectively. While the stubs capability is pretty neat, they don’t feel nearly as magical as the shims.

Consider that you have developed a pipeline component with a little bit of logic to inject a context property based on the current date/time. The scenario (although contrived) that I have come up with is that of an order processing system in which rush orders are all received through the same receive location. In that location is a custom pipeline that must promote a property to route to the warehouse that will be able to get the order picked and shipped the quickest (based on which warehouse is picking orders at the current hour, or will be doing so next). When testing the code, we will need to verify the behavior of the code at specific times.

While we could write the code in such a way that the retrieval of the current date/time was done through a special date/time provider class (which implements some interface specialized to that purpose), the logic is being re-used from another location – one which will not be modified.

BizTalk Server 2013 will rise to this occasion due to relying on Visual Studio 2012 as its development environment. We can use the included Microsoft Fakes framework to create a shim that will inject logic for all calls to DateTime.UtcNow to return a fixed DateTime object of our choosing.

getting Started with Shims

In order to get started, we need to instruct Visual Studio to generate some helper classes for the assembly or assemblies of our choosing. These classes will enable us to generate Stubs/Shims for classes within these assemblies.

For our solution, we will be working with the DateTime class, found in System. We can add a fakes assembly in two clicks via the context menu:


After adding the assembly, our project, and its references, look like this:


Now we will have to write the code in such a way that calls to DateTime.UtcNow will return the value of our choosing. In order to hook into those calls only within a specific portion of code, we will need to create a ShimsContext. Because the ShimsContext class implements IDisposable, we are able to wrap a using statement around it to provide better visibility of the scope it will control.

[sourcecode language=”csharp”]
public void RushOrderMarker_FirstPartOfDay_FirstWarehouseReturned()

// Arrange
var pipeline = GeneratePipeline();
var testMessage = GenerateTestMessage();

DateTime fakeTime = new DateTime(
year: 2013,
month: 01,
day: 01,
hour: 1, minute: 0, second: 0);

using (ShimsContext.Create())

System.Fakes.ShimDateTime.UtcNowGet = () => { return fakeTime; };
var expectedId = WarehouseIdentifiers[0];

// Act
var output = pipeline.Execute(testMessage);

// Assert
Assert.AreEqual(expectedId, Convert.ToString(warehouseId), "Incorrect warehouse id returned");




Here we assign logic directly to System.Fakes.ShimDateTime.UtcNowGet that will execute when any code within the scope after ShimsContext.Create() was called attempts to call DateTime.UtcNow. We then submit a message through our pipeline and verify that the correct warehouse id was promoted into the context of the message (based on the current time).

Know your Tools

If you’ve just made the move up to BizTalk Server 2013, it really is important that you not only know what feature set you have in the platform, but also what is available to you in the underlying platform, and the tools you use to create your applications.

If you want to learn BizTalk Server 2013 in the environment it was designed for, check out one of our upcoming BizTalk 2013 Developer Immersion, or BizTalk Server 2013 Deep Dive classes. The hands-on-lab environment is running the latest and greatest versions of Windows Server, SQL Server, and Visual Studio, so that you have the optimal BizTalk Server development experience.

If you would like to access sample code for this blog post, you can find it on github.

Brand new TFS 2012 Training for the Release of Visual Studio 2012

By moniquebu

Microsoft will release to manufacture (RTM) Visual Studio 2012 and Team Foundation Server 2012 in the first week of August with the official release planned for September. With the majority of users eligible for a “free” upgrade to the latest version through their MSDN Subscriptions, expect to see many organizations upgrading over the coming six months!

Why not hit the ground running by having your staff up skilled on the many great new features Microsoft have included in this release. Here’s just a sample of some of the new features we cover in our TFS 2012 courses:

  • A completely new web interface to help you interact with TFS
  • New Agile Planning tools to help you create and manage your product backlog
  • A task board to help you see the state of work in progress
  • A new feedback client to help ensure continuous feedback from your stakeholders
  • New exploratory testing features to help your testers create tests from exploratory testing sessions
  • Storyboarding support to allow you to create professional interactive storyboards to show your stakeholders
  • Support for teams within a Team Project with independent backlogs, dashboards and task boards.
  • Support for testing new Windows 8-style applications
  • Much, much more.

Our new range of 6 courses for Visual Studio 2012 TFS can provide your team with all the skills and knowledge necessary to make the maximum advantage from the new features in the 2012 release. Here is our line-up of new courses for TFS 2012:

  1. TFS 2012 Configuration and Administration
  2. Software Testing with Visual Studio 2012
  3. Test Automation, Web Performance, and Load Testing with VS 2012
  4. Managing Projects with TFS 2012
  5. ALM Solutions using TFS 2012
  6. TFS 2012 Developer Fundamentals