Run and Test
In the previous step, we created a simple plugin, registered a metric, and updated the metric's value.
Now, let's test the plugin to ensure it works as expected.
Modifying Program.cs
Instead of installing the plugin in MoBro every time we want to test it, the SDK provides a convenient utility called MoBroPluginBuilder
.
This utility allows us to easily create and run a plugin locally.
We'll modify the Program.cs
file as follows:
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();
With the changes in place, let's build and run the application to see our plugin in action!
Build and Run
Since this is a standard .NET console application, you can run it directly from your IDE.
Alternatively, execute the following command in the terminal (we'll use PowerShell throughout the tutorial):
dotnet run
Output
Once the plugin is built and executed, you should see 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
From the logs, you can see that:
- A new instance of the plugin was successfully created.
- The
first_metric
metric was registered. - The
first_metric
value was updated toHello World
.
Congratulations!
You've successfully created and run your first plugin! 🎉
Currently, the plugin provides a single metric (first_metric
), and its value does not change after being set.
In the next section, we will:
- Expand the functionality by updating metrics periodically.
- Dive into plugin settings for further customization.