LPRun 9.6.2

dotnet add package LPRun --version 9.6.2
                    
NuGet\Install-Package LPRun -Version 9.6.2
                    
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="LPRun" Version="9.6.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LPRun" Version="9.6.2" />
                    
Directory.Packages.props
<PackageReference Include="LPRun" />
                    
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 LPRun --version 9.6.2
                    
#r "nuget: LPRun, 9.6.2"
                    
#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 LPRun@9.6.2
                    
#: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=LPRun&version=9.6.2
                    
Install as a Cake Addin
#tool nuget:?package=LPRun&version=9.6.2
                    
Install as a Cake Tool

LINQPad Driver LPRun Unit/Integration Tests Runner

Latest build NuGet Downloads License

Table of Contents

Description

The LPRun is the LINQPad driver's unit/integration tests runner. Can be used for testing LINQPad drivers, e.g., CsvLINQPadDriver for LINQPad, or for running LINQPad scripts.

.NET Versions Supported

Scripts targeting .NET 6 up to .NET 10 are supported. Use the following LINQPad script to check which .NET is used by LPRun:

<Query Kind="Expression"/>

System.Environment.Version

Download

NuGet

Usage

Tested driver MUST NOT be installed via NuGet into LINQPad. In this case LPRun will use it instead of local one.

Setup

  1. Create test project.
  2. Add LPRun NuGet
  3. Create the following folder structure in test project:
LPRun # Created by LPRun NuGet.
    Templates # LINQPad script templates.
    Data      # Optional: Driver data files.

LINQPad Test Script Example

LPRun executes LINQPad test script. Test script uses AwesomeAssertions for assertion checks.

StringComparison.linq LINQPad test script example:

var original = Books.First();
var copy = original with { Title = original.Title.ToUpper() };

var expectedEquality = original.Title.Equals(copy.Title, context.StringComparison);

original.Equals(copy).Should().Be(expectedEquality, Reason());

original.GetHashCode()
    .Equals(copy.GetHashCode())
    .Should()
    .Be(expectedEquality, Reason());

Reason() method (prints exact line number if assertion fails) and context variable are injected by test below.

NUnit Test Example

Full NUnit test code can be found here.

[TestFixture]
public class LPRunTests
{
    [OneTimeSetUp]
    public void Init()
    {
        // Check that driver is not installed via NuGet.
        Driver.EnsureNotInstalledViaNuGet("CsvLINQPadDriver");

        // Install driver.
        Driver.InstallWithDepsJson(
            // The directory to copy driver files to.
            "CsvLINQPadDriver",
            // The LINQPad driver files.
            "CsvLINQPadDriver.dll",
            // The test folder path.
            "Tests");
    }

    [Test]
    [TestCaseSource(nameof(TestsData))]
    public async Task Execute_ScriptWithDriverProperties_Success(
        (string linqScriptName,
         string? context,
         ICsvDataContextDriverProperties driverProperties) testData)
    {
        var (linqScriptName, context, driverProperties) = testData;

        // Arrange: Create query connection header. Custom code can be added here.
        var queryConfig = GetQueryHeaders().Aggregate(
            new StringBuilder(),
            (stringBuilder, h) =>
        {
            stringBuilder.AppendLine(h);
            stringBuilder.AppendLine();
            return stringBuilder;
        }).ToString();

        // Arrange: Create test LNQPad script.
        // You can also use LinqScript.FromScript method.
        var linqScript = LinqScript.FromFile(
            $"{linqScriptName}.linq",
            queryConfig);

        // Act: Execute test LNQPad script.
        var (output, error, exitCode) =
            await Runner.ExecuteAsync(linqScript);

        // Assert.
        error.Should().BeNullOrWhiteSpace();
        exitCode.Should().Be(0);

        // Helpers.
        IEnumerable<string> GetQueryHeaders()
        {
            // Connection header.
            yield return ConnectionHeader.Get(
                "CsvLINQPadDriver",
                "CsvLINQPadDriver.CsvDataContextDriver",
                driverProperties,
                "System.Runtime.CompilerServices");

            // AwesomeAssertions helper.
            yield return
                 "string Reason([CallerLineNumber] int sourceLineNumber = 0) =>" +
                @" $""something went wrong at line #{sourceLineNumber}"";";

            // Test context.
            if (!string.IsNullOrWhiteSpace(context))
            {
                yield return $"var context = {context};";
            }
        }
    }

    private static IEnumerable<
        (string linqScriptName,
         string? context,
         ICsvDataContextDriverProperties driverProperties)> TestsData()
    {
        // Omitted for brevity.
    }
}

Tests can also be run in parallel:

[TestFixture]
public class LPRunTests
{
    [Test]
    [Parallelizable(ParallelScope.Children)]
    [TestCaseSource(nameof(ParallelizableTestsData))]
    public void Execute_ScriptWithDriverProperties_Success(
        (string linqScriptName,
         string? context,
         ICsvDataContextDriverProperties driverProperties,
         int index) testData)
    {
        // ...

        // Arrange: Create test LNQPad script.
        // You can also use LinqScript.FromScript method.
        var linqScript = LinqScript.FromFile(
            $"{linqScriptName}.linq",
            queryConfig,
            $"{linqScriptName}_{testData.index}");

        // ...
    }

    private static IEnumerable<
        (string linqScriptName,
         string? context,
         ICsvDataContextDriverProperties driverProperties,
         int index)> TestsData()
    {
        // Omitted for brevity.
    }

    // Parallelized tests data.
    private static IEnumerable<
        (string linqScriptName,
         string? context,
         ICsvDataContextDriverProperties driverProperties,
         int index)> ParallelizableTestsData() =>
        TestsData().AugmentWithFileIndex(
            static testData => testData.linqScriptName,
            static (testData, index) => { testData.index = index; return testData; });
}

Known Issues

Unit-testing Frameworks Support

Tested with NUnit. Other test frameworks should work as well.

macOS support

Running LPRun on macOS is not supported yet.

LINQPad Runtime Reference

Avoid referencing LINQPad.Runtime.dll in your tests, e.g. for Moq:

// LINQPad.Runtime.dll IConnectionInfo reference:
var connectionInfoMock = new Mock<LINQPad.Extensibility.DataContext.IConnectionInfo>();
var driverProperties   = new DriverProperties(connectionInfoMock.Object);

This code compiles but fails in runtime with Could not load file or assembly LINQPad.Runtime error. If you still need to reference it, add the following target which copies assembly to output folder of the test project:

<Target Name="CopyLINQPadRuntimeToOutput" AfterTargets="Build">
  <Copy SourceFiles="$(OutputPath)\LPRun\Bin\LINQPad.Runtime.dll" DestinationFolder="$(OutputPath)" UseHardlinksIfPossible="true" />
</Target>

Your can avoid referencing LINQPad.Runtime.dll assembly by using mock framework facilities, e.g. for Moq you can extract IDriverProperties interface and setup driver properties as follows:

var driverProperties = Mock.Of<IDriverProperties>(props =>
    props.BoolProp   == true     &&
    props.IntProp    == 42       &&
    props.StringProp == "string"
);

Authors

Credits

Tools

NuGet

Licenses

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 is compatible.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

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
9.6.2 104 1/12/2026
9.6.1 90 1/10/2026
9.5.10 124 12/27/2025
9.5.9 146 12/20/2025
9.5.4 175 12/14/2025
9.5.3 174 12/13/2025
9.5.2 481 12/10/2025
9.5.1 291 12/4/2025
9.4.6 654 12/1/2025
9.4.5 189 11/29/2025
9.4.4 195 11/28/2025
9.4.2 272 11/27/2025
9.4.1 255 11/23/2025
9.3.22 262 11/22/2025
8.10.2 366 9/6/2025
8.9.5 386 6/23/2025
8.9.4 331 6/5/2025
8.9.2 453 4/25/2025
8.9.1 515 4/15/2025
8.8.9 652 3/24/2025
8.8.8 439 3/9/2025
8.8.7 413 2/14/2025
8.8.6 390 2/7/2025
8.8.5 347 2/5/2025
8.8.4 422 1/29/2025
8.8.3 390 1/17/2025
8.8.2 372 1/11/2025
8.8.1 344 1/9/2025
8.7.4 427 12/17/2024
8.7.3 406 12/14/2024
8.7.2 389 11/28/2024
8.6.6 409 11/5/2024
8.6.5 354 11/1/2024
8.6.4 419 10/6/2024
8.6.2 447 9/15/2024
8.6.1 328 8/5/2024
8.5.5 312 7/26/2024
8.5.4 321 7/23/2024
8.5.3 379 7/20/2024
8.5.2 335 7/18/2024
8.5.1 440 7/4/2024
8.4.11 417 6/19/2024
8.4.10 348 6/11/2024
8.4.9 344 6/5/2024
8.4.8 305 5/27/2024
8.4.7 333 5/24/2024
8.4.5 369 5/22/2024
8.4.4 380 5/17/2024
8.4.3 357 5/14/2024
8.4.2 410 5/10/2024
8.4.1 412 4/30/2024
8.3.7 378 4/18/2024
8.3.6 416 4/14/2024
8.3.5 423 4/7/2024
8.3.3 393 3/21/2024
8.3.2 456 3/13/2024
8.3.1 392 3/12/2024
8.2.4 367 2/17/2024
8.2.3 376 2/13/2024
8.2.2 404 1/23/2024
8.1.6 372 1/17/2024
8.1.3 454 1/3/2024
8.1.2 409 12/27/2023
8.1.1 377 12/22/2023
8.0.18 405 12/5/2023
8.0.17 382 11/26/2023
8.0.16 397 11/25/2023
8.0.15 331 11/24/2023
8.0.14 380 11/22/2023
8.0.13 346 11/18/2023
8.0.12 347 11/17/2023
8.0.11 336 11/16/2023
8.0.10 359 11/15/2023
8.0.9 339 11/12/2023
7.8.10 386 2/14/2024
7.8.7 363 11/26/2023
7.8.6 517 9/14/2023
7.8.5 587 8/1/2023
7.8.4 498 7/13/2023
7.8.3 503 7/3/2023
7.8.2 496 6/16/2023
7.8.1 492 6/9/2023
7.7.15 480 5/31/2023
7.7.14 462 5/29/2023
7.7.13 480 5/23/2023
7.7.12 506 5/18/2023
7.7.11 530 5/10/2023
7.7.10 622 4/19/2023
7.7.9 624 4/4/2023
7.7.8 640 4/4/2023
7.7.7 696 3/21/2023
7.7.6 685 3/18/2023
7.7.4 633 3/13/2023
7.7.3 674 2/20/2023
7.7.2 636 2/13/2023
7.7.1 684 2/1/2023
7.6.6 797 1/5/2023
7.6.5 657 12/24/2022
7.6.4 695 12/7/2022
7.6.3 725 11/26/2022
7.6.2 698 11/16/2022
7.5.16 720 11/14/2022
7.5.15 699 11/13/2022
7.5.14 722 11/11/2022
7.5.13 710 11/10/2022
7.5.12 765 10/31/2022
7.5.11 785 10/30/2022
7.5.10 761 10/25/2022
7.5.9 761 10/9/2022
7.5.8 744 10/6/2022
7.5.7 769 10/3/2022
7.5.6 784 9/26/2022
7.5.5 817 9/23/2022
7.5.4 795 9/20/2022
7.5.3 813 9/16/2022
7.5.2 835 8/28/2022
7.5.1 861 8/26/2022
7.4.9.1 881 8/3/2022
7.4.8 868 7/31/2022
7.4.7 897 7/25/2022
7.4.6 905 7/19/2022
7.4.5 938 7/15/2022
7.4.4 921 7/6/2022
7.4.3 935 6/8/2022
7.4.2 922 5/11/2022
7.4.1 889 5/3/2022
7.3.9 908 4/19/2022
7.3.6 890 3/25/2022
7.3.5 881 3/17/2022
7.3.4 897 3/15/2022
7.3.2 842 2/23/2022
7.3.1 835 2/17/2022
6.14.11 759 9/1/2021
6.14.10 881 7/18/2021
6.13.14 764 5/10/2021
6.13.13 803 5/5/2021

LPRun 9.6.2