Skip to main content

Run and test

In the previous step we've created a simple plugin, created and registered a metric and finally updated the value of our metric.
Now we're going to try and run our plugin to see if it works as expected.

Program.cs

Since we don't want to actually install the plugin to MoBro every time we want to test it, the SDK offers a handy MoBroPluginBuilder.
This builder can be used to easily create and run a plugin locally.

Se we're going to modify our Program.cs:

Plugin.Example/Program.cs
using MoBro.Plugin.SDK;

// create and start the plugin to test it locally
var plugin = MoBroPluginBuilder
.Create<Plugin.Example.Plugin>()
.Build();

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

So let's run it and see what happens!

Build and run

Since this is just a regular .NET console application we can simply run it from the IDE.
Or just execute the following command from console (we're going to use Powershell throughout the tutorial):

dotnet run

Output

After building and running the plugin, you should get the following output:

PS C:\dev\mobro-data-plugins\Plugin.Example> dotnet run
01:32:33.054 [INF] Creating new plugin instance
01:32:33.104 [DBG] Registered Metric: first_metric
01:32:33.109 [DBG] Value of metric first_metric updated to: Hello World
01:32:33.110 [INF] Invoking 'init' function on plugin

As you can see from the logs, a new instance of our plugin was created.
Then our plugin registered our first_metric metric and updated its value to Hello World afterwards.

Congratulations, you've created your first plugin!

For now this plugin just provides a single metric whose value doesn't change after it has been set once.
In the next section we will expand this plugin further and start updating metrics periodically and also take a quick look at plugin settings.