Bny.UnitTests 1.1.0
C# library for unit testing
Loading...
Searching...
No Matches
Tester Class Reference

Class for unit testing More...

Inheritance diagram for Tester:

Public Member Functions

 Tester (string name, bool formatted=true)
 Creates new tester More...
 
bool Test (TestFunction tf, LogAmount logAmount=LogAmount.Default, [CallerArgumentExpression(nameof(tf))] string caller="")
 Executes the given test More...
 
IEnumerator< AssertionGetEnumerator ()
 Enumerates all the assertions More...
 

Static Public Member Functions

static Tester Test< T > (LogAmount logAmount=LogAmount.Default, TextWriter? @out=null, bool formatted=true)
 Executes all the tests in the type More...
 
static Tester Test (Type test, LogAmount logAmount=LogAmount.Default, TextWriter? @out=null, bool formatted=true)
 Executes all the tests in the type More...
 
static Tester[] TestAll (LogAmount logAmount=LogAmount.Default, TextWriter? @out=null, bool formatted=true)
 Executes all the tests in all the types with the UnitTestAttribute More...
 

Properties

TextWriter Out = Console.Out [get, set]
 The output for the results, stdout by default
 
string Name [get]
 Name of the test group
 
bool Formatted = true [get]
 Determines whether the output should be formatted
 
bool Success = true [get]
 True if all tests passed
 

Detailed Description

Class for unit testing

Constructor & Destructor Documentation

◆ Tester()

Tester.Tester ( string  name,
bool  formatted = true 
)

Creates new tester

Parameters
namename of the test group
formattedtrue if the output should be formatted, otherwise false

Member Function Documentation

◆ GetEnumerator()

IEnumerator< Assertion > Tester.GetEnumerator ( )

Enumerates all the assertions

Returns
Assertion enumerator

◆ Test() [1/2]

bool Tester.Test ( TestFunction  tf,
LogAmount  logAmount = LogAmount.Default,
[CallerArgumentExpression(nameof(tf))] string  caller = "" 
)

Executes the given test

Parameters
tfTest to execute
logAmountHow much to log
callerName of the test, this is set automatically
Returns
True if all the assertions in the test passed

◆ Test() [2/2]

static Tester Tester.Test ( Type  test,
LogAmount  logAmount = LogAmount.Default,
TextWriter? @  out = null,
bool  formatted = true 
)
static

Executes all the tests in the type

Parameters
testType with the tests
logAmountHow much to log
outTest results output, null is stdout
formattedTrue if the output should be formatted, otherwise false
Returns

◆ Test< T >()

static Tester Tester.Test< T > ( LogAmount  logAmount = LogAmount.Default,
TextWriter? @  out = null,
bool  formatted = true 
)
static

Executes all the tests in the type

Template Parameters
TType with the tests
Parameters
logAmountHow much to log
outTest results output, null is stdout
formattedTrue if the output should be formatted, otherwise false
Returns
Test with the summary

◆ TestAll()

static Tester[] Tester.TestAll ( LogAmount  logAmount = LogAmount.Default,
TextWriter? @  out = null,
bool  formatted = true 
)
static

Executes all the tests in all the types with the UnitTestAttribute

Parameters
logAmountHow much to log
outTest results output, null is stdout
formattedTrue if the output should be formatted
Returns
Array of all the test results

The documentation for this class was generated from the following file: