Ox.BizTalk.TestComponents 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Ox.BizTalk.TestComponents --version 1.0.2
NuGet\Install-Package Ox.BizTalk.TestComponents -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ox.BizTalk.TestComponents" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ox.BizTalk.TestComponents --version 1.0.2
#r "nuget: Ox.BizTalk.TestComponents, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Ox.BizTalk.TestComponents as a Cake Addin
#addin nuget:?package=Ox.BizTalk.TestComponents&version=1.0.2

// Install Ox.BizTalk.TestComponents as a Cake Tool
#tool nuget:?package=Ox.BizTalk.TestComponents&version=1.0.2

Ox.BizTalk.TestComponents

This library is meant to be a very basic implementation of BizTalk interfaces that can be used with test frameworks for the unit testing of BizTalk components without having to execute code in the BizTalk engine.

It is not guaranteed to behave in the same was as the BizTalk engine (in fact, I gaurantee it won't!), but to aid in stubbing components.

All methods are marked as virtual so you can override bits as you feel fit.

Building

It is built against .NET 4.7.2 as this covers BizTalk 2016 which is still in support.

Usage

This code should only be used in unit tests when the BizTalk runtime is unavailable. It doesn't fully implement all the required bits, and most certainly doesn't do it in a clever way.

A common approach used in these test classes is to allow you to register event handlers on methods which use the MethodCalledEventArgs class, which simply contains the arguments passed into a method, in signature order. This allows you to check that a method is being called with the expected values. For example:

// Create a task to track when the callback has been completed.
var eventsComplete = new TaskCompletionSource<bool>();

// Setup some unique test data
var testData = Guid.NewGuid().ToString();

// Create an inline function to handle our event and test the result
void ReceiverShuttingDown(object sender, MethodCalledEventArgs e)
{
    // Test that the inserted data matches our input
    Assert.AreEqual(testData, (string)e.Args[0]);

    // Mark the test complete
    eventsComplete.SetResult(true);
}

// Setup the test class
var proxy = new TestTransportProxy();

// Register our event handler
proxy.OnReceiverShuttingDown += ReceiverShuttingDown;

// Submit some test data
proxy.ReceiverShuttingDown(testData, null);

// Wait for the event handler to be called, or fail after a timeout period
if(!eventsComplete.Task.Wait(TEST_TIMEOUT))
{
    Assert.Fail("Tests methods were not called.");
}

Naturally this exmaple is rather dim, because it's checking that the data we pass in is the data that is logged, which will always be the case. Where this approach is useful when we have classes that call these methods as a dependency and we want to test whether that was called correctly.

Interfaces/abstract classes covered:

Orchestration

  • XLANGPart (TestXLANPart)
  • XLANGMessage (TestXLANGMessage)

Pipelines

  • IBaseMessagePart (TestMessagePart)
  • IBaseMessageFactory (TestMessageFactory)
  • IBaseMessageContext (TestMessageContext)
  • IBaseMessage (TestMessage)

Adapters

  • IBTTransportBatch (TestTransportBatch)
  • IBTTransportConfig (TestTransportConfig)
  • IBTTransportProxy (TestTransportProxy)
  • IBTBatchCallBack (TestBatchCallBack)

General

  • IResourceTracker (TestResourceTracker)
  • IBasePropertyBag (TestProperyBag)
  • IPropertyBag (TestPropertyBag)

Changes

There are amany methods that aren't implemented, you may need to add some functionality.

Please submit a pull request with changes.

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 251 3/20/2023
1.0.2 415 4/14/2022

v1.0.0 - Initial release