LPRun 6.14.11

Install-Package LPRun -Version 6.14.11
dotnet add package LPRun --version 6.14.11
<PackageReference Include="LPRun" Version="6.14.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LPRun --version 6.14.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LPRun, 6.14.11"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install LPRun as a Cake Addin
#addin nuget:?package=LPRun&version=6.14.11

// Install LPRun as a Cake Tool
#tool nuget:?package=LPRun&version=6.14.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Latest build NuGet Downloads License

LINQPad Driver LPRun Unit/Integration Tests Runner

Table of Contents

Description

LINQPad driver LPRun unit/integration tests runner. Can be used for testing LINQPad 6 drivers using LPRun or for running LINQPad scripts.

Website

LPRun is a part of CsvLINQPadDriver for LINQPad 6. LPRun source code can be found here.

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 Fluent Assertions 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() =>
        // Copy driver to LPRun drivers folder.
        Driver.Install("CsvLINQPadDriver",
            "CsvLINQPadDriver.dll",
            "CsvHelper.dll",
            "Humanizer.dll"
        );

    [Test]
    [TestCaseSource(nameof(TestsData))]
    public void 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.
        var linqScript = LinqScript.Create($"{linqScriptName}.linq", queryConfig);

        // Act: Execute test LNQPad script.
        var (output, error, exitCode) =
            Runner.Execute(linqScript, TimeSpan.FromMinutes(2));

        // 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");

            // FluentAssertions 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.
    }
}

Known Issues

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

Authors

  • Ivan Ivon (ivan.ivon@gmail.com)

Credits

Tools

NuGet

License

MIT, see LICENSE file for details.

  • .NETStandard 2.1

    • 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
6.14.11 129 9/1/2021
6.14.10 180 7/18/2021
6.13.14 164 5/10/2021
6.13.13 109 5/5/2021

LPRun 6.14.10
Added .NET 5.0 support.