Skip to main content

Testing

To quickly test or debug a plugin, it can simply be started as a .NET console application.
For more thorough integration testing, the plugin can be temporarily installed to MoBro.

Start locally

To start the plugin for testing or debug purposes, it does not actually need to be installed to MoBro.
The SDK contains the MoBroPluginBuilder class that can be utilized to instantiate a plugin and run it locally like any other .NET console application.

Values for plugin settings can be directly provided to the builder.

The returned plugin exposes some functions for interaction like Pause() and Resume() and also allows to apply a new set of settings.

Program.cs
// create and start the plugin to test it locally
var plugin = MoBroPluginBuilder
.Create<Plugin.Example.Plugin>()
.WithSetting("update_frequency", "1")
.Build();

// wait for manual trigger to apply the new settings
Console.ReadLine();

// the plugin exposes multiple functions like Pause(), Resume(), ApplySettings(...), etc.
plugin.ApplySettings(new Dictionary<string, string> {{"update_frequency", "2"}});

// prevent the program from exiting immediately
Console.ReadLine();

The program can be started like any other .NET console application by a simple: dotnet run

MoBro

As a final integration test, a plugin can be installed to MoBro directly.

Publish as .zip

In order to install a plugin, it first needs to be published and packed as a .zip file.

CLI

The easiest way to publish a plugin as a .zip file is to use the MoBro Plugin CLI.
A simple invocation of the publish command from within the project directory is all it takes:

mobro publish .

After executing the command, the plugin will be published to a .zip file named [plugin_name]_[version].zip in the same directory.
The output directory can be optionally specified by the --output option (defaults to: .).

Command line / Script

A plugin can also be published and packed via the command line.
Instead of using the CLI or manually performing all the commands like we did in the Getting started: Publish and install section, we can create a short publish.bat script that will perform all the necessary steps:

Plugin.Example/publish.bat
@ECHO OFF

@REM publish the plugin
dotnet publish^
--framework net7.0^
--runtime win-x64^
--self-contained false^
--configuration Release^
-p:DebugType=None^
-p:DebugSymbols=false^
-p:GenerateRuntimeConfigurationFiles=false^
--output %1^
.

@REM zip the plugin folder
"C:\Program Files\7-Zip\7z.exe" a -tzip "%1.zip" "%1\*"

@REM delete the plugin folder
rmdir /S /Q "%1"

The script requires a single parameter which defines the name of the folder to publish to.
It can be invoked like this:

./publish.bat ExamplePlugin_v1

Install

A plugin can be temporarily installed to MoBro for testing purposes by utilizing the MoBro Plugin CLI or the REST API of the MoBro data service.

This requires MoBro to be installed and running on the PC.

Note

MoBro will periodically scan for and uninstall any plugins that are not published via the official marketplace and therefore considered unknown.

CLI

Installing a plugin for testing purposes can be achieved by a single CLI command. Simply pass the published .zip file as an argument to the install command:

mobro install .\example_plugin_0.0.1.zip
tip

If you just quickly want to install a plugin to test some changes and don't actually need the published .zip file, you can skip the publish step and just install the plugin directly from the project directory:

mobro install .

REST

In order to install a plugin using the REST Api, execute a POST request to localhost:42069/api/plugins with a form-data body containing the unique plugin name as specified in the mobro_plugin_config.json as well as the created .zip file from the previous step.

Example request using Postman:

Postman

After installing the plugin it will be available in MoBro just like any other plugin that was installed via the marketplace:

Running plugin