TDW.Marv.Testing 0.9.1

dotnet add package TDW.Marv.Testing --version 0.9.1
                    
NuGet\Install-Package TDW.Marv.Testing -Version 0.9.1
                    
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="TDW.Marv.Testing" Version="0.9.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TDW.Marv.Testing" Version="0.9.1" />
                    
Directory.Packages.props
<PackageReference Include="TDW.Marv.Testing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TDW.Marv.Testing --version 0.9.1
                    
#r "nuget: TDW.Marv.Testing, 0.9.1"
                    
#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.
#:package TDW.Marv.Testing@0.9.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TDW.Marv.Testing&version=0.9.1
                    
Install as a Cake Addin
#tool nuget:?package=TDW.Marv.Testing&version=0.9.1
                    
Install as a Cake Tool

TDW.Marv.Testing

Test helpers for Marv IRC bot plugins. Provides builders for handler contexts, mock factories, and a plugin test harness.

Who is this for?

This package is for plugin authors writing unit tests for their Marv plugins. It pairs with TDW.Marv.Core.

Quick start

Add this package alongside your preferred test framework (xUnit, NUnit, etc.) and NSubstitute (included as a dependency).

using Marv.Testing;
using NSubstitute;
using Xunit;

public class HelloPluginTests
{
    [Fact]
    public async Task Hello_RepliesWithGreeting()
    {
        var harness = PluginTestHarness<HelloPlugin>.Create();
        await harness.LoadAsync();

        var ctx = CommandContextBuilder.Create("hello")
            .InChannel("#test").From("alice").Build();

        await harness.HandleCommandAsync(ctx);

        await harness.Bot.Received().SendMessageAsync(
            "#test", Arg.Is<string>(s => s.Contains("alice")), Arg.Any<CancellationToken>());
    }
}

Context builders

Reduce test setup to 2-3 lines with fluent builders:

// Command context
var ctx = CommandContextBuilder.Create("greet", "world")
    .InChannel("#test").From("alice").Build();

// Regex match context
var ctx = RegexMatchContextBuilder.Create(@"hello (\w+)", "hello world")
    .InChannel("#test").From("alice").Build();

// Typed events
var evt = EventBuilder<MessageEvent>.Create(raw => new MessageEvent
{
    Sender = MockUser.Create("alice"),
    Text = "hello",
    RawMessage = raw
}).Build();

Mock factories

Factory Description
MockBot.Create(nick?, prefix?) NSubstitute mock of IBot
MockUser.Create(nick, account?) Mock IUser
MockChannel.Create(name) Mock IChannel
DummyIrcMessage.Privmsg / .Notice / .Empty Pre-built IRC messages
DummyIrcMessage.PrivmsgFrom(nick, target, text) Custom PRIVMSG

Plugin test harness

PluginTestHarness<T> wires up DI with mocked dependencies:

var harness = PluginTestHarness<MyPlugin>.Create(
    configureServices: services =>
    {
        services.AddSingleton(Options.Create(new MyConfig { ... }));
    });

await harness.LoadAsync();

// Access the plugin and mock bot
harness.Plugin;  // MyPlugin instance
harness.Bot;     // IBot mock (use .Received() assertions)

Documentation

Full API reference: Plugin API docs

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.9.1 138 7/3/2026
0.9.0 123 6/28/2026
0.8.0 111 6/24/2026
0.7.2 113 6/17/2026
0.7.1 109 6/17/2026
0.7.0 221 6/17/2026
0.6.2 114 6/14/2026