Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/intellitect/testtools.console
TestTools.Console is a simple end-to-end test framework for .NET console applications.
https://github.com/intellitect/testtools.console
console dotnet hacktoberfest nuget testing testing-tools
Last synced: 1 day ago
JSON representation
TestTools.Console is a simple end-to-end test framework for .NET console applications.
- Host: GitHub
- URL: https://github.com/intellitect/testtools.console
- Owner: IntelliTect
- License: mit
- Created: 2022-08-01T22:50:59.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-11T10:47:49.000Z (8 months ago)
- Last Synced: 2024-04-28T07:51:44.894Z (6 months ago)
- Topics: console, dotnet, hacktoberfest, nuget, testing, testing-tools
- Language: C#
- Homepage: https://www.nuget.org/packages/IntelliTect.TestTools.Console
- Size: 104 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [TestTools.Console](https://www.nuget.org/packages/IntelliTect.TestTools.Console/): [![NuGet](https://img.shields.io/nuget/v/IntelliTect.TestTools.Console.svg)](https://www.nuget.org/packages/IntelliTect.TestTools.Console/)
Console is a simple end-to-end test framework for .NET console applications.
Check out the package at
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.
```csharp
string view =
@"Please enter 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>>".
```csharp
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.
```csharp
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>>".
```csharp
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.