System::CollectionAssertHelper Struct Reference

Heler API for collection-related operations. More...

#include "test_tools.h"

Static Public Member Functions

template<typename T1 , typename T2 >
static System::SharedPtr< System::Collections::Generic::Dictionary< T1, int32_t > > MakeDiff (const System::SharedPtr< System::Collections::Generic::IEnumerable< T1 >> &expected, const System::SharedPtr< System::Collections::Generic::IEnumerable< T2 >> &actual)
 Calculates 'diff' between two collections. For every element of each collection as key resulting value will be positive if element occures more times in "expected" collection, negative if element occures more times in "actual" collection, and zero if element occures equal times in each collection. More...
 
static bool CheckDiffForAll (const std::function< bool(int)> &pred, const System::SharedPtr< System::Collections::Generic::ICollection< int32_t >> &values)
 Checks that all collection elements adhere the predicate. More...
 
static bool CheckDiffForAny (const std::function< bool(int)> &pred, const System::SharedPtr< System::Collections::Generic::ICollection< int32_t >> &values)
 Checks that any collection element adheres the predicate. More...
 
template<typename T >
static System::String IEnumerableToStr (const System::SharedPtr< System::Collections::Generic::IEnumerable< T >> &ie)
 Converts collection to string by joining string representations of elements. More...
 
template<typename T1 , typename T2 >
static System::String CollectionsToMsg (const System::String &extra_msg, const System::SharedPtr< System::Collections::Generic::IEnumerable< T1 >> &expected, const System::SharedPtr< System::Collections::Generic::IEnumerable< T2 >> &actual)
 Serializes two collections for message representation. More...
 
static System::String ToFullMessage (const System::String &message=u"")
 Formats string to be used as message text. More...
 

Detailed Description

Heler API for collection-related operations.

Member Function Documentation

◆ CheckDiffForAll()

static bool System::CollectionAssertHelper::CheckDiffForAll ( const std::function< bool(int)> &  pred,
const System::SharedPtr< System::Collections::Generic::ICollection< int32_t >> &  values 
)
inlinestatic

Checks that all collection elements adhere the predicate.

Parameters
predPredicate to check.
valuesValues to check.
Returns
False if check fails for any element, true if all pass.

◆ CheckDiffForAny()

static bool System::CollectionAssertHelper::CheckDiffForAny ( const std::function< bool(int)> &  pred,
const System::SharedPtr< System::Collections::Generic::ICollection< int32_t >> &  values 
)
inlinestatic

Checks that any collection element adheres the predicate.

Parameters
predPredicate to check.
valuesValues to check.
Returns
True if check suceeds for any element, false if all pass.

◆ CollectionsToMsg()

template<typename T1 , typename T2 >
static System::String System::CollectionAssertHelper::CollectionsToMsg ( const System::String extra_msg,
const System::SharedPtr< System::Collections::Generic::IEnumerable< T1 >> &  expected,
const System::SharedPtr< System::Collections::Generic::IEnumerable< T2 >> &  actual 
)
inlinestatic

Serializes two collections for message representation.

Template Parameters
T1Expected collection element type.
T2Actual collection element type.
Parameters
extra_msgA custom string which is inserted before the expected value in the resulting message
expectedExpected collection.
actualActual collection.
Returns
User-friendly message on collections' contents.

◆ IEnumerableToStr()

template<typename T >
static System::String System::CollectionAssertHelper::IEnumerableToStr ( const System::SharedPtr< System::Collections::Generic::IEnumerable< T >> &  ie)
inlinestatic

Converts collection to string by joining string representations of elements.

Template Parameters
TCollection element type.
Parameters
ieCollection to check.
Returns
Joint values of collection.

◆ MakeDiff()

template<typename T1 , typename T2 >
static System::SharedPtr<System::Collections::Generic::Dictionary<T1, int32_t> > System::CollectionAssertHelper::MakeDiff ( const System::SharedPtr< System::Collections::Generic::IEnumerable< T1 >> &  expected,
const System::SharedPtr< System::Collections::Generic::IEnumerable< T2 >> &  actual 
)
inlinestatic

Calculates 'diff' between two collections. For every element of each collection as key resulting value will be positive if element occures more times in "expected" collection, negative if element occures more times in "actual" collection, and zero if element occures equal times in each collection.

Template Parameters
T1Expected collection element type.
T2Actual collection element type.
Parameters
expectedExpected collection.
actualActual collecion.
Returns
Map of per-value comparison results as per rules above.

◆ ToFullMessage()

static System::String System::CollectionAssertHelper::ToFullMessage ( const System::String message = u"")
inlinestatic

Formats string to be used as message text.

Parameters
messageString to format.
Returns
String prefixed with 'Message: ' text and replaced with '<empty>' if empty.