In 2012 I created a TestTool to test Business Rules that you can use in the ESB Toolkit for BizTalk 2010. (See the post: Testing ESB Toolkit 2.1 Business Rules for BizTalk 2010) The sample was downloaded over 350 times so I thought maybe it would be nice to port it to BizTalk 2013 and add some features to the tool!

The following changes and additions have been made:

  • The sample project ported to the .NET framework 4.5 with Visual Studio 2012.
  • Show trace output from the BRE engine in the Tool.
  • Test if the Itinerary that is resolved with Business Rules also exists in the Itinerary Store database and display it in the Tool.
  • Test if the Map that is resolved with Business Rules also exists in the GAC, execute it and display the result in the Tool.
  • Some small changes in the user interaction.

 

Using the Tool

With the sample Tool policies can be tested that have one of the following vocabularies from the ESB Toolkit:

  • ESB.EndPointInfo
    • Set the Outbound Transport Location properties of a Send Port.
  • ESB.TransformInfo
    • Set the Transform Type.
  • ESB.Itinerary
    • Set the Itinerary Name.

 

Specifying Itineraries

How to dynamically select an itinerary based on the content of a received message and how to test it.
 
Create a Policy with the specific Business Rules in the Business Rule Composer which select an itinerary.
BRE_Composer_ESB_Itinerary
 
How to test Specifying an itinerary

Open the XML file in the TestTool and specify the following properties:

  • Select the “ESB.Itinerary” Fact.
  • Enter the name of the Policy in containing the Business Rules.
  • Enter the Document Type of the message.
Test_ResolveItinerary
 

When you click on the “Test” button, the policy is executed against the BRE engine.

  • The trace output of the BRE engine is displayed on the Trace tab.
  • The Action tab is automatically selected and shown when the test result of one of the rules is true.
  • The tool tests if the itinerary exists in the Itinerary Store database.
    • When this is the case it is shown in the Tool otherwise you get an warning message.
TestResult_Trace_ResolveItinerary
On the Trace tab are the Test results of the BRE engine displayed.
 
TestResult_Actions_ResolveItinerary
 On the Action tab the resolved itinerary name. The resolved itinerary is displayed on the Itinerary tab.
  
How to use the Policy
Configure the Itinerary Selector pipeline component to use a business rules policy to select the appropriate itinerary.
Pipeline_ResolverConnectionString_BRI_Resolver_Policy
 
 

Dynamic Transformation

How to dynamically select a map based on the content of a message and how to test it.
 
Create a Policy with the specific Business Rules in the Business Rule Composer which select the map.
BRE_Composer_ESB_Map
 
How to test Dynamic transformation

Open the XML file in the TestTool and specify the following properties:

  • Select the “ESB.TransformInfo” Fact.
  • Enter the name of the Policy in containing the Business Rules.
  • Enter the Document Type of the message.
 

When you click on the “Test” button, the policy is executed against the BRE engine.

  • The trace output of the BRE engine is displayed on the Trace tab.
  • The Action tab is automatically selected and shown when the test result of one of the rules is true.
  • The tool tests if the Map exists in the GAC.
    • When this is the case it is executed and shown otherwise you get an warning message.
TestResult_Actions_ResolveMap
 
How to use the Policy
Configure the properties of the Resolver to use a business rules policy to select the appropriate map.
Itinerary_TransformService_Properties_BRE_Resolver_Policy
 
 

Dynamic Routing

How to dynamically select a destination based on the content of a message and how to test it.
 
Create a Policy with the specific Business Rules in the Business Rule Composer which select the destination.
BRE_Composer_ESB_EndPointInfo
 
How to test Dynamic Routing

Open the XML file in the TestTool and specify the following properties:

  • Select the “ESB.EndPointInfo” Fact.
  • Enter the name of the Policy in containing the Business Rules.
  • Enter the Document Type of the message.
TestResult_Actions_EndPoint
 
How to use the Policy
Configure the properties of the Resolver to use a business rules policy to select the appropriate destination.
Itinerary_RoutingService_Properties_BRE_Resolver_Policy
 
 

Conclusion

The sample is designed for BizTalk 2013 but if you want to use it for BizTalk 2010 you can change the target framework and remove the custom MapHelper class that performs the BizTalk transformations. Add a reference again to the ESB.TransformServices.dll assembly from the ESB Toolkit and use these classes to call a BizTalk map.

You can download the sample tool with the source code here:
Testing Business Rules in ESB toolkit 2.2 for BizTalk 2013