Adapter Testing - GhostLabsAB/Examples GitHub Wiki
There is a special project type “Ghost Adapter Tester” for testing and debugging an adapter included in the adapter package. When created you will simulate the message processing and build your Link from code instead from the Ghost Studio. You should create the Tester project in the same solution as the adapter you want to test. The Link generation is done by creating a MockupSetup class in which you add adapters, create Nodes and do all the bindings that will form the Link.
MockupSetup setup = new MockupSetup(new MockupSettings
{
UseRx = false,
EnableMultiThreading = true,
//Proxy = new WebProxy("http://proxy.domain.com:8080")
//{
// UseDefaultCredentials = true
//}
});
There are two ways of adding an Adapter; by local code or by a NuGet package.
AdapterConfigInfo adapter_config = new AdapterConfigInfo
{
NuGetPkg = "GhostNodes.SourceAssembly.File"
};
Or
AdapterConfigInfo adapter_config = new AdapterConfigInfo
{
FullPath = @"C:\Adapters\YourAdapter\bin\Debug\netstandard2.0\GhostNodes.SourceAssembly.YourAdapter.dll",
};
setup.Adapters.Add(adapter_config);
When adapter is loaded from a NuGet package the adapter will be downloaded from the GhostNodes NuGet repository. This is so you may use existing adapters to build a Link with your own custom adapter you want to debug and test.
In the other option you need to point to the adapter assembly file which should be on your local file system.
To configure the adapter, you will need to create a NodeConfigInfo object that uses the adapter.
NodeConfigInfo node_info = new NodeConfigInfo()
{
Name = "My Source Node",
NodeType = NodeType.Source,
AdapterConfigInfo = adapter_config,
Parameters = new List<Param>()
{
Param.Create("MyPath", @"D:\GhostNodes Test\FileDrop3"),
Param.Create("MyFilter", "*.*")
}
};
Here you will need to match the NodeType correctly and at a minimum add Params for all mandatory properties. To finally build the Link you need to add and bind the Nodes.
setup.AddNode(node_info);
setup.AddNode(node_other_info, new List<Guid>() { node_info.UniqueId });
Then the Link is finally ready to be processed. This is done by starting the Message-Engine
setup.StartEngine();
Set Adapter Tester project as “Startup Project” and set some breakpoints in the Adapter. Hit F5 to start debugging…