{"id":24379749,"url":"https://github.com/i2van/lprun","last_synced_at":"2025-03-12T14:13:17.768Z","repository":{"id":233186221,"uuid":"786247606","full_name":"i2van/LPRun","owner":"i2van","description":"The LPRun is the LINQPad driver's unit/integration tests runner. Can be used for testing LINQPad 8/LINQPad 7/LINQPad 6 drivers or for running LINQPad scripts.","archived":false,"fork":false,"pushed_at":"2024-05-22T11:12:54.000Z","size":68460,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-22T11:31:20.506Z","etag":null,"topics":["dotnetcore31","integration-testing","linqpad","linqpad6","linqpad7","linqpad8","lprun","net6","net7","net8","testing","testing-tools","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/i2van.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-13T21:36:28.000Z","updated_at":"2024-05-22T11:12:57.000Z","dependencies_parsed_at":"2024-05-10T09:39:25.380Z","dependency_job_id":null,"html_url":"https://github.com/i2van/LPRun","commit_stats":null,"previous_names":["i2van/lprun"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i2van%2FLPRun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i2van%2FLPRun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i2van%2FLPRun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i2van%2FLPRun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/i2van","download_url":"https://codeload.github.com/i2van/LPRun/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242692337,"owners_count":20170228,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnetcore31","integration-testing","linqpad","linqpad6","linqpad7","linqpad8","lprun","net6","net7","net8","testing","testing-tools","unit-testing"],"created_at":"2025-01-19T07:19:44.548Z","updated_at":"2025-03-12T14:13:17.749Z","avatar_url":"https://github.com/i2van.png","language":"C#","readme":"# LINQPad Driver LPRun Unit/Integration Tests Runner\n\n[![Latest build](https://github.com/i2van/LPRun/workflows/build/badge.svg)](https://github.com/i2van/LPRun/actions)\n[![NuGet](https://img.shields.io/nuget/v/LPRun)](https://www.nuget.org/packages/LPRun)\n[![Downloads](https://img.shields.io/nuget/dt/LPRun)](https://www.nuget.org/packages/LPRun)\n[![License](https://img.shields.io/badge/license-MIT-yellow)](https://opensource.org/licenses/MIT)\n\n## Table of Contents\n\n* [Description](#description)\n* [LPRun .NET Versions](#lprun-net-versions)\n* [Download](#download)\n* [Usage](#usage)\n  * [Setup](#setup)\n  * [LINQPad Test Script Example](#linqpad-test-script-example)\n  * [NUnit Test Example](#nunit-test-example)\n* [Known Issues](#known-issues)\n  * [Unit-testing Frameworks Support](#unit-testing-frameworks-support)\n  * [LINQPad Runtime Reference](#linqpad-runtime-reference)\n* [Troubleshooting](#troubleshooting)\n* [Authors](#authors)\n* [Credits](#credits)\n  * [Tools](#tools)\n  * [NuGet](#nuget)\n* [Licenses](#licenses)\n\n## Description\n\nThe LPRun is the LINQPad driver's unit/integration tests runner. Can be used for testing [LINQPad 8](https://www.linqpad.net/LINQPad8.aspx)/[LINQPad 7](https://www.linqpad.net/LINQPad7.aspx)/[LINQPad 6](https://www.linqpad.net/LINQPad6.aspx) drivers,\ne.g., [CsvLINQPadDriver for LINQPad 8/7/6/5](https://github.com/i2van/CsvLINQPadDriver), or for running LINQPad scripts.\n\n## LPRun .NET Versions\n\n.NET versions supported by LPRun are listed below. In case of unsupported version LPRun fallbacks to the latest production .NET installed.\n\n| LPRun |      .NET 9.0      |     .NET 8.0       |      .NET 7.0      |      .NET 6.0      |      .NET 5.0      |      .NET 3.1      |\n|:-----:|:------------------:|:------------------:|:------------------:|:------------------:|:------------------:|:------------------:|\n|   8   | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |                    |                    |\n|   7   |                    |                    | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |\n\nUse the following script to check the .NET version used by LPRun:\n\n```csharp\n\u003cQuery Kind=\"Expression\"/\u003e\n\nSystem.Environment.Version\n```\n\n## Download\n\n[![NuGet](https://img.shields.io/nuget/v/LPRun)](https://www.nuget.org/packages/LPRun)\n\n## Usage\n\nTested driver **MUST NOT** be installed via NuGet into LINQPad. In this case LPRun will use it instead of local one.\n\n### Setup\n\n1. Create test project.\n2. Add LPRun [![NuGet](https://img.shields.io/nuget/v/LPRun)](https://www.nuget.org/packages/LPRun)\n3. Create the following folder structure in test project:\n\n```text\nLPRun # Created by LPRun NuGet.\n    Templates # LINQPad script templates.\n    Data      # Optional: Driver data files.\n```\n\n### LINQPad Test Script Example\n\nLPRun executes LINQPad test script. Test script uses [Fluent Assertions](https://github.com/fluentassertions/fluentassertions) for assertion checks.\n\n[StringComparison.linq](https://github.com/i2van/CsvLINQPadDriver/blob/master/Tests/CsvLINQPadDriverTest/LPRun/Templates/StringComparison.linq) LINQPad test script example:\n\n```csharp\nvar original = Books.First();\nvar copy = original with { Title = original.Title.ToUpper() };\n\nvar expectedEquality = original.Title.Equals(copy.Title, context.StringComparison);\n\noriginal.Equals(copy).Should().Be(expectedEquality, Reason());\n\noriginal.GetHashCode()\n    .Equals(copy.GetHashCode())\n    .Should()\n    .Be(expectedEquality, Reason());\n```\n\n`Reason()` method (prints exact line number if assertion fails) and `context` variable are injected by [test](https://github.com/i2van/CsvLINQPadDriver/blob/master/Tests/CsvLINQPadDriverTest/LPRunTests.cs) [below](#nunit-test-example).\n\n### NUnit Test Example\n\nFull NUnit test code can be found [here](https://github.com/i2van/CsvLINQPadDriver/blob/master/Tests/CsvLINQPadDriverTest/LPRunTests.cs).\n\n```csharp\n[TestFixture]\npublic class LPRunTests\n{\n    [OneTimeSetUp]\n    public void Init()\n    {\n        // Check that driver is not installed via NuGet.\n        Driver.EnsureNotInstalledViaNuGet(\"CsvLINQPadDriver\");\n\n        // Install driver.\n        Driver.InstallWithDepsJson(\n            // The directory to copy driver files to.\n            \"CsvLINQPadDriver\",\n            // The LINQPad driver files.\n            \"CsvLINQPadDriver.dll\",\n            // The test folder path.\n            \"Tests\");\n    }\n\n    [Test]\n    [TestCaseSource(nameof(TestsData))]\n    public async Task Execute_ScriptWithDriverProperties_Success(\n        (string linqScriptName,\n         string? context,\n         ICsvDataContextDriverProperties driverProperties) testData)\n    {\n        var (linqScriptName, context, driverProperties) = testData;\n\n        // Arrange: Create query connection header. Custom code can be added here.\n        var queryConfig = GetQueryHeaders().Aggregate(\n            new StringBuilder(),\n            (stringBuilder, h) =\u003e\n        {\n            stringBuilder.AppendLine(h);\n            stringBuilder.AppendLine();\n            return stringBuilder;\n        }).ToString();\n\n        // Arrange: Create test LNQPad script.\n        // You can also use LinqScript.FromScript method.\n        var linqScript = LinqScript.FromFile(\n            $\"{linqScriptName}.linq\",\n            queryConfig);\n\n        // Act: Execute test LNQPad script.\n        var (output, error, exitCode) =\n            await Runner.ExecuteAsync(linqScript);\n\n        // Assert.\n        error.Should().BeNullOrWhiteSpace();\n        exitCode.Should().Be(0);\n\n        // Helpers.\n        IEnumerable\u003cstring\u003e GetQueryHeaders()\n        {\n            // Connection header.\n            yield return ConnectionHeader.Get(\n                \"CsvLINQPadDriver\",\n                \"CsvLINQPadDriver.CsvDataContextDriver\",\n                driverProperties,\n                \"System.Runtime.CompilerServices\");\n\n            // FluentAssertions helper.\n            yield return\n                 \"string Reason([CallerLineNumber] int sourceLineNumber = 0) =\u003e\" +\n                @\" $\"\"something went wrong at line #{sourceLineNumber}\"\";\";\n\n            // Test context.\n            if (!string.IsNullOrWhiteSpace(context))\n            {\n                yield return $\"var context = {context};\";\n            }\n        }\n    }\n\n    private static IEnumerable\u003c\n        (string linqScriptName,\n         string? context,\n         ICsvDataContextDriverProperties driverProperties)\u003e TestsData()\n    {\n        // Omitted for brevity.\n    }\n}\n```\n\nTests can also be run in parallel:\n\n```csharp\n[TestFixture]\npublic class LPRunTests\n{\n    [Test]\n    [Parallelizable(ParallelScope.Children)]\n    [TestCaseSource(nameof(ParallelizableTestsData))]\n    public void Execute_ScriptWithDriverProperties_Success(\n        (string linqScriptName,\n         string? context,\n         ICsvDataContextDriverProperties driverProperties,\n         int index) testData)\n    {\n        // ...\n\n        // Arrange: Create test LNQPad script.\n        // You can also use LinqScript.FromScript method.\n        var linqScript = LinqScript.FromFile(\n            $\"{linqScriptName}.linq\",\n            queryConfig,\n            $\"{linqScriptName}_{testData.index}\");\n\n        // ...\n    }\n\n    private static IEnumerable\u003c\n        (string linqScriptName,\n         string? context,\n         ICsvDataContextDriverProperties driverProperties,\n         int index)\u003e TestsData()\n    {\n        // Omitted for brevity.\n    }\n\n    // Parallelized tests data.\n    private static IEnumerable\u003c\n        (string linqScriptName,\n         string? context,\n         ICsvDataContextDriverProperties driverProperties,\n         int index)\u003e ParallelizableTestsData() =\u003e\n        TestsData().AugmentWithFileIndex(\n            static testData =\u003e testData.linqScriptName,\n            static (testData, index) =\u003e { testData.index = index; return testData; });\n}\n```\n\n## Known Issues\n\n### Unit-testing Frameworks Support\n\nTested with [NUnit](https://github.com/nunit/nunit). Other test frameworks should work as well.\n\n### LINQPad Runtime Reference\n\nAvoid referencing `LINQPad.Runtime.dll` in your tests, e.g. for [Moq](https://github.com/moq/moq4):\n\n```csharp\n// LINQPad.Runtime.dll IConnectionInfo reference:\nvar connectionInfoMock = new Mock\u003cLINQPad.Extensibility.DataContext.IConnectionInfo\u003e();\nvar driverProperties   = new DriverProperties(connectionInfoMock.Object);\n```\n\nThis 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:\n\n```xml\n\u003cTarget Name=\"CopyLINQPadRuntimeToOutput\" AfterTargets=\"Build\"\u003e\n  \u003cCopy SourceFiles=\"$(OutputPath)\\LPRun\\Bin\\LINQPad.Runtime.dll\" DestinationFolder=\"$(OutputPath)\" UseHardlinksIfPossible=\"true\" /\u003e\n\u003c/Target\u003e\n```\n\nYour can avoid referencing `LINQPad.Runtime.dll` assembly by using mock framework facilities, e.g. for [Moq](https://github.com/moq/moq4) you can extract `IDriverProperties` interface and setup driver properties as follows:\n\n```csharp\nvar driverProperties = Mock.Of\u003cIDriverProperties\u003e(props =\u003e\n    props.BoolProp   == true     \u0026\u0026\n    props.IntProp    == 42       \u0026\u0026\n    props.StringProp == \"string\"\n);\n```\n\n## Authors\n\n* [Ivan Ivon](https://github.com/i2van)\n* [LINQPad.Runtime](https://www.linqpad.net/LINQPad8.aspx)/[LPRun](https://www.linqpad.net/lprun.aspx) binaries ([license](https://www.linqpad.net/eula.txt)) by [Joseph Albahari](https://www.albahari.com/)\n\n## Credits\n\n### Tools\n\n* [LINQPad 8](https://www.linqpad.net/LINQPad8.aspx)\n* [LINQPad Command-Line and Scripting](https://www.linqpad.net/lprun.aspx)\n\n### NuGet\n\n* [Fluent Assertions](https://github.com/fluentassertions/fluentassertions)\n* [Moq](https://github.com/moq/moq4)\n* [NUnit](https://github.com/nunit/nunit)\n\n## Licenses\n\n* [LICENSE](https://github.com/i2van/LPRun/blob/main/LICENSE) ([MIT](https://opensource.org/licenses/MIT))\n* [LINQPad End User License Agreement](https://www.linqpad.net/eula.txt)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi2van%2Flprun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fi2van%2Flprun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi2van%2Flprun/lists"}