GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - IntelliTect/TestTools.Console: TestTools.Console is a simple end-to-end test framework for .NET console applications.

BranchesTags
Open more actions menu

Latest commit

 

History

174 Commits
174 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.vscode
.vscode
 
 
IntelliTect.TestTools.Console.Tests
IntelliTect.TestTools.Console.Tests
 
 
IntelliTect.TestTools.Console
IntelliTect.TestTools.Console
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
Directory.Build.props
Directory.Build.props
 
 
Directory.Packages.props
Directory.Packages.props
 
 
IntelliTect.TestTools.Console.slnx
IntelliTect.TestTools.Console.slnx
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
global.json
global.json
 
 

Repository files navigation

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.

About

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

www.nuget.org/packages/IntelliTect.TestTools.Console

Topics

consoledotnethacktoberfestnugettestingtesting-tools

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing
Activity
Custom properties

Stars

1 star

Watchers

2 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.