IntelliTect.TestTools.Console 1.0.0

dotnet add package IntelliTect.TestTools.Console --version 1.0.0
NuGet\Install-Package IntelliTect.TestTools.Console -Version 1.0.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="IntelliTect.TestTools.Console" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IntelliTect.TestTools.Console --version 1.0.0
#r "nuget: IntelliTect.TestTools.Console, 1.0.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.
// Install IntelliTect.TestTools.Console as a Cake Addin
#addin nuget:?package=IntelliTect.TestTools.Console&version=1.0.0

// Install IntelliTect.TestTools.Console as a Cake Tool
#tool nuget:?package=IntelliTect.TestTools.Console&version=1.0.0

TestTools.Console: NuGet

Console is a simple end-to-end test framework for .NET console applications.

Check out the package at https://www.nuget.org/packages/IntelliTect.TestTools.Console

This currently has non-optimal nomenclature and is not guaranteed to be efficient, but it appears to work.

Usage

Basic Usage

The view variable contains a sample view to test for. Within it, the << and >> symbols indicate that the inner content is entered into the console by the user -- including the newline, as they would press Enter.

string view =
@"Please enter something: <<Something
>>You said 'Something'.";

IntelliTect.TestTools.Console.ConsoleAssert.Expect(view, () => { MyMethod() } );

Wildcard Patterns

Performs a unit test on a console-based method. A "view" of what a user would see in their console is provided as a string, where their input (including line-breaks) is surrounded by double less-than/greater-than signs, like so: "Input please: <<Input>>".

string expected = $@"(abstract, 1)
(abstract, 2)
(abstract, 3)*
(add\*, 1)";

IntelliTect.TestTools.Console.ConsoleAssert.ExpectLike(expected, () =>
{
    Program.Main();
});

Normalize Line Endings

Normalizes all line endings of the input string into the current Environment newline string.

string expected = $@"test123
and2*
and this is my *
expected message";

expected = IntelliTect.TestTools.Console.ConsoleAssert.NormalizeLineEndings(expected);

IntelliTect.TestTools.Console.ConsoleAssert.ExpectLike(expected, () =>
{
    Program.Main();
});
Execute Process and TestGeneration

Performs a unit test on a console-based executable. what a user would see in their console is provided as a string, where their input (including line-breaks) is surrounded by double less-than/greater-than signs, like so: "Input please: <<Input>>".

        string expected = $@"*
Pinging * ?::1? with 32 bytes of data:
Reply from ::1: time*";
        string pingArgs = "-c 4 localhost";
        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
        {
            pingArgs = pingArgs.Replace("-c ", "-n ");
        }
        else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
        {
            expected = $@"PING *(* (::1)) 56 data bytes
64 bytes from * (::1): icmp_seq=1 ttl=64 time=* ms*";
        }

        ConsoleAssert.ExecuteProcess(
            expected,
            "ping", pingArgs, out string _, out _);

... More to come later.

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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on IntelliTect.TestTools.Console:

Repository Stars
IntelliTect/EssentialCSharp
This project contains the source code for the book Essential C# by Mark Michaelis (Addison-Wesley).
Version Downloads Last updated
1.0.0 1,781 11/11/2023
0.7.1 4,020 8/3/2022
0.7.0 576 8/2/2022
0.6.0-ci-20220127-2 2,793 1/28/2022
0.6.0-ci-20200919-1 2,449 9/21/2020
0.6.0-ci-20200504-2 19,222 5/5/2020
0.6.0-ci-20200502-2 318 5/4/2020
0.6.0-ci-20190618-2 1,575 6/18/2019
0.6.0-ci-20190617-1 383 6/17/2019
0.6.0-ci-20190611-1 391 6/11/2019
0.6.0-ci-20190611.2 296 6/11/2019
0.5.1-beta-180924-1 604 9/25/2018
0.5.1-beta-180920-2 557 9/20/2018
0.5.1-beta-180920-1 645 9/20/2018
0.5.0-beta-180813-1 688 8/15/2018