While working on the BTS2013 project, I started writing unit test for Schemas and Maps. I found that unit test for maps do not work anymore with the BTS2013 upgrade. I keep on getting “Transform failure” error messages. I with the help of one of my colleague figure out actually Microsoft had missed on to upgrade TestableMapBase class. They still using the BTSXslTransform instead of using XslCompiledTransform.
This post is to show how we can resolve this issue by creating wrapper class and changing the TestableMapBase class to use XslCompiledTransform.
I used reflector to pull out source code from the Microsoft.BizTalk.TestTools. Re-factor it to use in the wrapper class and change the use of BTSXslTransform to XslCompiledTransform and re-written the PerformTransform method as per below.
The below code is using XslCompiledTransform method rather then BTSXslTransform in TestMapTransform.cs.
The below code is re-written to call Transform Load and transform method in TestableMapBase.cs.
To prove this I have created the two test method, TestMethod (Unit_Sample) is referencing our wrapper class and other is TestMethod (Unit_Sample_2) is using the Microsoft BizTalk Test tools.
You can see from the below that the Unit_Sample passed the unit test while Unit_Sample_2 failed.
The unit test source code is on https://skydrive.live.com/redir?resid=867C3BC1B30476B2%21149. Happy doing unit test now :). Thank you Johaan for sticking with me :).