TestFramework.Simple 0.3.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package TestFramework.Simple --version 0.3.0
                    
NuGet\Install-Package TestFramework.Simple -Version 0.3.0
                    
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="TestFramework.Simple" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TestFramework.Simple" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="TestFramework.Simple" />
                    
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 TestFramework.Simple --version 0.3.0
                    
#r "nuget: TestFramework.Simple, 0.3.0"
                    
#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 TestFramework.Simple@0.3.0
                    
#: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=TestFramework.Simple&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=TestFramework.Simple&version=0.3.0
                    
Install as a Cake Tool

TestFramework.Simple

TestFramework.Simple is an extension package for TestFramework.Core.

It adds lightweight triggers for common cases where you do not want to create a full custom Step<T> class.

Install

dotnet add package TestFramework.Simple

Quick Start

using TestFramework.Core.Timelines;
using TestFramework.Simple;
using Xunit;

public class SimpleSample
{
    [Fact]
    public async Task InlineAction()
    {
        string? message = null;
        const string expectedMessage = "Action executed";

        Timeline timeline = Timeline.Create()
            .Trigger(SimpleExt.Trigger.Action(() => message = expectedMessage))
            .Build();

        TimelineRun run = await timeline.SetupRun().RunAsync();

        run.EnsureRanToCompletion();
        Assert.Equal(expectedMessage, message);
    }
}

Variable-Aware Action

using TestFramework.Core.Variables;
using TestFramework.Simple;

Timeline timeline = Timeline.Create()
    .SetVariable("name", Var.Const("Alex"))
    .Trigger(SimpleExt.Trigger.Action(vars => Console.WriteLine($"Hello {vars[new VariableIdentifier("name")]}"), Var.Ref<string>("name")))
    .Build();

Choosing An Action(...) Overload

Use the smallest overload that matches the information you need:

  • Action(Action action) when the step only needs to run code.
  • Action(Action<Dictionary<VariableIdentifier, object?>> action, params VariableReferenceGeneric[] variables) when the step only needs resolved variables.
  • Action(Action<Dictionary<VariableIdentifier, object?>, Dictionary<ArtifactIdentifier, ArtifactInstanceGeneric>> action, VariableReferenceGeneric[] variables, params ArtifactIdentifier[] artifacts) when the step needs both variables and artifacts.
  • Action(Action<IServiceProvider, ScopedLogger, Dictionary<VariableIdentifier, object?>, Dictionary<ArtifactIdentifier, ArtifactInstanceGeneric>> action, VariableReferenceGeneric[] variables, params ArtifactIdentifier[] artifacts) when the step also needs dependency-injected services or logging.

The richer overloads intentionally trade some simplicity for flexibility. Variable and artifact values are exposed through dictionaries keyed by their identifiers.

Artifact-Aware Action

using TestFramework.Core.Artifacts;
using TestFramework.Core.Variables;
using TestFramework.Simple;

ArtifactIdentifier payloadArtifact = new("payload");

Timeline timeline = Timeline.Create()
    .Trigger(SimpleExt.Trigger.Action((vars, artifacts) =>
    {
        string? name = (string?)vars[new VariableIdentifier("name")];
        ArtifactInstanceGeneric payload = artifacts[payloadArtifact];
        Console.WriteLine($"Processing {name} with artifact {payload.Identifier}");
    }, [Var.Ref<string>("name")], payloadArtifact))
    .Build();

Full-Context Action

using TestFramework.Core.Logging;
using TestFramework.Core.Variables;
using TestFramework.Simple;

Timeline timeline = Timeline.Create()
    .Trigger(SimpleExt.Trigger.Action((serviceProvider, logger, vars, artifacts) =>
    {
        logger.LogInformation("Executing inline action with {VariableCount} variables and {ArtifactCount} artifacts.", vars.Count, artifacts.Count);
    }, [Var.Ref<string>("name")]))
    .Build();

Announcing Something Mid-Run

SimpleExt.Trigger.Message(msg, caption) writes [caption] msg to the run log. It works everywhere and blocks nothing, so it is the right choice for anything that just needs to be visible in the output.

Timeline timeline = Timeline.Create()
    .Trigger(SimpleExt.Trigger.Message("Waiting for the downstream system", "Progress"))
    .Build();

Windows MessageBox Behavior

SimpleExt.Trigger.MessageBox(...) is Windows-only because it calls user32.dll. It is for a human sitting in front of the run.

  • Use it only on Windows test machines.
  • Do not rely on it for unattended CI runs. Set TESTFRAMEWORK_MESSAGEBOX=off in CI and the default invoker returns immediately without showing a dialog, so an agent with nobody to click OK does not sit on a modal window until the step times out.
  • Replace MessageBoxTrigger.Invoker to route the text somewhere else, or to assert on it in a test.
  • Prefer Message(...) — the same shape, logged rather than shown — when you need a cross-platform step, or Action(...) for arbitrary inline work.

Handling Failures

  • Action(...) fails immediately if you pass a null delegate.
  • Variable-based overloads require identifiers for every supplied variable reference.
  • MessageBox(...) requires Windows and will not behave correctly on non-Windows platforms.

Includes

  • SimpleExt.Trigger.Action(...) for inline custom actions
  • SimpleExt.Trigger.Message(...) for a captioned line in the run log, on any platform
  • SimpleExt.Trigger.MessageBox(...) for simple Windows message box flows

Target Frameworks

  • .NET 8 (net8.0)
  • .NET 10 (net10.0)
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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

Adds Trigger.Message(...), a cross-platform trigger that writes a captioned line to the run log. Prefer it over Trigger.MessageBox(...), which is Windows-only and blocks on a modal dialog - unusable headless or in CI.
MessageBoxTrigger.Invoker is now public and settable so the dialog can be replaced in a test, and setting TESTFRAMEWORK_MESSAGEBOX=off makes it return without showing a dialog. The interactive default is unchanged.