-
Notifications
You must be signed in to change notification settings - Fork 24
Alternative Bindings
Charlie Mott edited this page Nov 18, 2017
·
6 revisions
Wiki: Home > Tips and Tricks
The Alternative Bindings technique was first described by Michael Stephenson in his testing series of blogs. On developer machines and lower test environments, it is often necessary to isolate dependencies from external systems using stubs. This stub may require some alterations to the bindings that go beyond just environment settings. It could be that an entirely different adapter needs to be used.
Add XmlPreprocess syntax as follows to the PortBindingsMaster.xml file
<!-- #ifdef _xml_preprocess -->
... Rest of bindings file. All ${ReplacementTokens} must be wrapped within xml pre-processor.
<!-- #endif -->
<!-- #if GetProperty("Environment")=="Local Development" -->
<TransportTypeData>...${Setting1}...</TransportTypeData>
<!-- #endif -->
<!-- #if GetProperty("Environment")!="Local Development" -->
<TransportTypeData>...${Setting1}...</TransportTypeData>
<!-- #endif -->
<!-- #ifdef _xml_preprocess -->
... Rest of bindings file. All ${ReplacementTokens} must be wrapped within xml pre-processor.
<!-- #endif -->
Note: I could not get this to work using #else syntax. It would not substitute the ${MySetting2} tag. Instead, I have used two #if statements.
- Try to replace the minimum amount of configuration so that as much of the target port bindings are included in your tests. e.g. Replace just the WCF Bindings in the TransportTypeData field rather than the whole send port.
- Check you need to introduce the technique above. Sometimes there is a more simple way. For example, if you need to disable a custom pipeline component, try using the "opt-in" pattern by including an IsEnabled property. This pipeline component can then be disabled more easily using a standard replacement token.
- Also see TransMock for an alternative approach to Alternative Bindings. In this framework, the Mockifier replaces the actual adapter configuration in receive locations and send ports that are marked for mocking in the binding file.
- Original Source: https://biztalkdeployment.codeplex.com/discussions/226299
- XmlPreprocessor: http://xmlpreprocess.sourceforge.net
- Alternative Bindings technique: http://geekswithblogs.net/michaelstephenson/archive/2009/05/12/132052.aspx.
- TransMock: https://transmock.codeplex.com