This post aims to provide some general guidance on testing for .net components which will be used within a BizTalk project. In terms of .net components I am mainly talking about the following:
- .net helper classes used by orchestrations
- .net classes used within Maps
I have done seperate posts in this series (or am planning) which covers the following types of .net component which has more specific testing requirements:
- Custom Pipeline Components
- Custom Adapters
Some recommendations to help you with this testing includes:
1. The key thing with .net helper type components is that they should be tested exactly in the same way you would test any normal C# code. You would use MsTest or NUnit style tests and should use a code coverage tool to help ensure you test all cases.
2. It is a good practice to abstract the logic of a component from the reliance on any BizTalk objects which may make the component more complicated. This can be handled using something like the facade pattern. Testing would be simplified because you could unit test all of the logic and then just have fairily simple code at the interface to the component.
3. You may also want to use something like the Rhino Mocks framework to help when you have a class which has dependancies on the BizTalk objects. An example of this might be a class where you pass in an XLANGMessage or IBaseMessage. Normally these are difficult to test but Rhino Mocks allows you to create a dynamic mock representing the XLANGMessage object which you can now use to test with.
4. Ensure your tests are part of your continuous integration process
5. Ensure you monitor code coverage