The framework can be used without any configuration being specified in any config files if desired but there are a couple of useful features which using the config file supports.

The config you would supply only needs to go in the app.config file for your testing project. The main use of the configuration is to allow you to specify the config settings for ports and server addresses in one place. This means if you change your tests to run against a different environment its easy to change which addresses you are pointing to.

The below is an example of the configuration.


<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>

    <section name="appfx.hl7.testing.utilities" type="AppFx.HL7.Testing.Utilities.Configuration.HL7TestConfiguration, AppFx.HL7.Testing.Utilities"/>

  </configSections>

  <appfx.hl7.testing.utilities>
    <applicationsToStub>
      <add applicationName="HIS" portName="HIS_Default" port="24000"/>
      <add applicationName="ADT" portName="ADT_Default" port="25000"/>
    </applicationsToStub>
    
    <applicationsToSendTo>
      <add applicationName="BizTalk" portName="ADT_Receive" port="22000" server="g-poc-bz-t-02"/>
      <add applicationName="BizTalk" portName="HIS_Receive" port="23000" server="g-poc-bz-t-02"/>      
    </applicationsToSendTo>

  </appfx.hl7.testing.utilities>
  
</configuration>


Applications to Stub

This is used to specify the settings for applications you want to stub out and create a receiver to simulate. The below gives an example of using the framework configuration to get the details of the stub so we know the port number to use when initiating the listener.


               var applicationSettings = HL7TestConfiguration.Current.ApplicationsToStub.Get(applicationName, portName);
                if(applicationSettings == null)
                {
                    throw new ApplicationException(string.Format("There is no application configuration for: Application Name = {0}, Port Name = {1}", applicationName, portName));
                }
                
                var listenerName = string.Format("{0}-{1}", applicationName, portName);
                MLLPListenerManager.Instance.AddStandardLocalListener(listenerName, applicationSettings.Port, myProcessor);

Applications to Send to

When we want to send a message to an MLLP application we can use the applicationToSendTo configuration to abstract the server address and port number of the destination to the configuration file.

The below code shows a sample of using the config section of the framework to get these settings


 var applicationSettings = HL7TestConfiguration.Current.ApplicationsToSendTo.Get(applicationName, portName);

            var message = ScenarioContext.Current[ADTRequestMessageKey] as string;

            var mllpMessage = new MLLPMessage(message);
            var sender = new MLLPSender();
            var responseMllpMessage = sender.Send(applicationSettings.Server, applicationSettings.Port, mllpMessage);

Last edited Apr 21, 2014 at 1:41 AM by michaelstephenson, version 2