I was just refactoring an orchestration today and to help me test it I wanted to query HAT to ensure the orchestration had completed successfully, BizUnit doesn't have a build in step to do this so I created my own which is easy to do thanks to the extensibility of BizUnit. I guess I could probably have used one of the BizUnit database steps and written some fiddly SQL to do this, but a new task would make this fairly reusable.
The xml to use my step is below:
Some key points to this XML are:
- The DurationToCheckSeconds is as it says a period of time that HAT will be checked for to see if your orchestration has completed
- The ExpectedNoOrchestrations allows you to indicate how many instances you expect to find from this query
- OrchestrationName is the name of the orchestration you are looking for
- FailIfLess allows you to indicate if an exception should be thrown by the step if it finds less than the expected number of orchestrations
- FailIfMore allows you to indicate if an exception should be thrown by the step if it finds more than the expected number of orchestrations
- HATConnectionString is the connection to the HAT database
In my step I will execute a query which will check for instances which started after the start of my BizUnit test (the step gets this from the BizUnit context).
In the example above im basically saying that I want to find atleast 1 instance of my orchestration completing since my test began.
As we all know HAT data sometimes takes a little while to be available. In my step depending on how you configure the settings above it will not necessarily wait the whole duration to check before confirming that the test was ok. For example In my usage above it lets me confirm that at least 1 instance is in HAT since my test begun, but I don't want to wait for ages ensuring that only 1 instance is there. Because my tests all run serially I can assume that so long as I find 1 instance then my test is good and I can continue as soon as I find it.
The code for the BizUnit step is available to download at the following link: