C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
AnalyzeReTesting.Utilities.AssertApi Class Reference

Static Public Member Functions

static void AllPropertiesEqual< T > (T objExpected, T objActual)
 Check that all properties of the two objects match. A deep object value equivalency test.
 
static bool AlmostEquals (double d1, double d2, double tolerance=DEFAULT_DOUBLE_EQUIVALENCE_TOLERANCE)
 Determines if two doubles are equivalent within the specified tolerance.
 
static Action< APIRequestExceptionApiExceptionTest (HttpStatusCode expectedStatusCode)
 Generate a function that will test a REST request exception in a standard way.
 
static void DatesAreEqual (DateTime? dt1, DateTime? dt2, string propertyName="DateTime")
 Asserts that two dates are equal within the supported precision. Analyze Re only supports a precision of up to 3 decimal places, the rest is truncated.
 
static void DoublesAreEqual (double expected, double actual, Func< string > message, double? relative_tolerance=null)
 Determines if two doubles are equivalent within the accepted tolerance.
 
static void DoublesAreEqual (double expected, double actual, string message=null, double? relative_tolerance=null)
 Determines if two doubles are equivalent within the accepted tolerance.
 
static void ExceptionThrown< T > (Action action, Action< T > exceptionTest=null)
 Asserts that an exception is thrown while invoking an action, and optionally performs an additional test as to whether the exception thrown is correct.
 
static bool FileContentsAreEqual (string expected, string actual, StringComparison comparisonType=StringComparison.InvariantCulture)
 Determines whether the two strings are equal, ignoring differences in line ending styles and trailing white space.
 
static void IsValidUUID (string toCheck)
 Assert that the string is a valid UUID.
 
static void LogExceptionDetails (Exception ex)
 Creates a useful log of the exception details, and in request/response resulting in the error if any is available.
 
static void MethodIsAllowed (Action request, string methodName, bool methodAllowed=true)
 Wrap a request in a tryGet with some formatting for testing purposes.
 
static void PostResponseMatches< T > (T objPosted, T objReturned)
 Check that all properties of POST response matches expectations of how the API responds to requests. A deep object value equivalency test.
 
static void PutResponseMatches< T > (T original, T objPut, T objReturned)
 Check that all properties of a PUT response matches expectations of how the API responds to requests. A deep object value equivalency test.
 
static void ReferencesResolved (object obj)
 
static bool TryFindException< T > (Exception ex, out T foundException)
 Convert the current exception to the specified Exception type T , or check if any InnerExceptions match that type.
 

Static Public Attributes

const double DEFAULT_DOUBLE_EQUIVALENCE_TOLERANCE = 1E-14
 

Detailed Description

Definition at line 25 of file AssertApi.cs.

Member Function Documentation

◆ AllPropertiesEqual< T >()

static void AnalyzeReTesting.Utilities.AssertApi.AllPropertiesEqual< T > ( T  objExpected,
T  objActual 
)
inlinestatic

Check that all properties of the two objects match. A deep object value equivalency test.

Parameters
objExpectedThe expected object.
objActualThe actual object.
Type Constraints
T :IAPIType 

Definition at line 129 of file AssertApi.cs.

◆ AlmostEquals()

static bool AnalyzeReTesting.Utilities.AssertApi.AlmostEquals ( double  d1,
double  d2,
double  tolerance = DEFAULT_DOUBLE_EQUIVALENCE_TOLERANCE 
)
inlinestatic

Determines if two doubles are equivalent within the specified tolerance.

Parameters
d1The expected value of 'actual'
d2The value to compare to 'expected'
tolerance(Default DEFAULT_DOUBLE_EQUIVALENCE_TOLERANCE) The relative (ratio) tolerance for the equivalency test.

Definition at line 622 of file AssertApi.cs.

◆ ApiExceptionTest()

static Action< APIRequestException > AnalyzeReTesting.Utilities.AssertApi.ApiExceptionTest ( HttpStatusCode  expectedStatusCode)
inlinestatic

Generate a function that will test a REST request exception in a standard way.

Parameters
expectedStatusCodeThe expected status code of the REST response error.
Returns
A function that will test exceptions (which can be passed to the AssertApi.ExceptionThrown method.

Definition at line 539 of file AssertApi.cs.

◆ DatesAreEqual()

static void AnalyzeReTesting.Utilities.AssertApi.DatesAreEqual ( DateTime dt1,
DateTime dt2,
string  propertyName = "DateTime" 
)
inlinestatic

Asserts that two dates are equal within the supported precision. Analyze Re only supports a precision of up to 3 decimal places, the rest is truncated.

Parameters
dt1The first DateTime.
dt2The second DateTime.
propertyNameThe property name to use in the error message if the DateTimes are not equal.

Definition at line 635 of file AssertApi.cs.

◆ DoublesAreEqual() [1/2]

static void AnalyzeReTesting.Utilities.AssertApi.DoublesAreEqual ( double  expected,
double  actual,
Func< string message,
double relative_tolerance = null 
)
inlinestatic

Determines if two doubles are equivalent within the accepted tolerance.

Parameters
expectedThe expected value of 'actual'
actualThe value to compare to 'expected'
messageGets the error message to raise if and only if the assertion fails.
relative_toleranceThe double comparison relative (ratio) tolerance.

Definition at line 594 of file AssertApi.cs.

◆ DoublesAreEqual() [2/2]

static void AnalyzeReTesting.Utilities.AssertApi.DoublesAreEqual ( double  expected,
double  actual,
string  message = null,
double relative_tolerance = null 
)
inlinestatic

Determines if two doubles are equivalent within the accepted tolerance.

Parameters
expectedThe expected value of 'actual'
actualThe value to compare to 'expected'
message(Optional) The message to output if the assertion fails.
relative_toleranceThe double comparison relative (ratio) tolerance.

Definition at line 608 of file AssertApi.cs.

◆ ExceptionThrown< T >()

static void AnalyzeReTesting.Utilities.AssertApi.ExceptionThrown< T > ( Action  action,
Action< T exceptionTest = null 
)
inlinestatic

Asserts that an exception is thrown while invoking an action, and optionally performs an additional test as to whether the exception thrown is correct.

Template Parameters
TThe expected exception type
Parameters
actionThe action to perform.
exceptionTestA optional action (presumably an assertion) to execute on the returned exception, presuming it was of the expected type.
Type Constraints
T :Exception 

Definition at line 68 of file AssertApi.cs.

◆ FileContentsAreEqual()

static bool AnalyzeReTesting.Utilities.AssertApi.FileContentsAreEqual ( string  expected,
string  actual,
StringComparison  comparisonType = StringComparison::InvariantCulture 
)
inlinestatic

Determines whether the two strings are equal, ignoring differences in line ending styles and trailing white space.

Parameters
expectedThe original string.
actualThe string that should match.
comparisonTypeThe StringComparison to use.
Returns
True if the string contents are equivalent.

Definition at line 528 of file AssertApi.cs.

◆ IsValidUUID()

static void AnalyzeReTesting.Utilities.AssertApi.IsValidUUID ( string  toCheck)
inlinestatic

Assert that the string is a valid UUID.

Parameters
toCheckThe string to check.

Definition at line 644 of file AssertApi.cs.

◆ LogExceptionDetails()

static void AnalyzeReTesting.Utilities.AssertApi.LogExceptionDetails ( Exception  ex)
inlinestatic

Creates a useful log of the exception details, and in request/response resulting in the error if any is available.

This generates a significant amount of console output, and should only be invoked for unwanted exceptions, not for expected errors scenarios.

Definition at line 51 of file AssertApi.cs.

◆ MethodIsAllowed()

static void AnalyzeReTesting.Utilities.AssertApi.MethodIsAllowed ( Action  request,
string  methodName,
bool  methodAllowed = true 
)
inlinestatic

Wrap a request in a tryGet with some formatting for testing purposes.

Parameters
requestAsserts that a request either is or is not permitted by the server.
methodNameThe name of the method (only used creating meaningful error messages)
methodAllowedTrue if the method should be allowed (2XX response), or false if it should return a 404 method not allowed.

Definition at line 98 of file AssertApi.cs.

◆ PostResponseMatches< T >()

static void AnalyzeReTesting.Utilities.AssertApi.PostResponseMatches< T > ( T  objPosted,
T  objReturned 
)
inlinestatic

Check that all properties of POST response matches expectations of how the API responds to requests. A deep object value equivalency test.

Parameters
objPostedThe object included in the POST body, which is expected to match the resulting response object.
objReturnedThe POST response that was returned by the server.
Type Constraints
T :IAPIResource 

Definition at line 150 of file AssertApi.cs.

◆ PutResponseMatches< T >()

static void AnalyzeReTesting.Utilities.AssertApi.PutResponseMatches< T > ( T  original,
T  objPut,
T  objReturned 
)
inlinestatic

Check that all properties of a PUT response matches expectations of how the API responds to requests. A deep object value equivalency test.

Parameters
originalThe original resource retrieved from the server before performing a PUT.
objPutThe object used to generate the PUT request body.
objReturnedThe PUT response that was returned by the server.
Type Constraints
T :IAPIResource 

Definition at line 172 of file AssertApi.cs.

◆ ReferencesResolved()

static void AnalyzeReTesting.Utilities.AssertApi.ReferencesResolved ( object  obj)
inlinestatic

Definition at line 558 of file AssertApi.cs.

◆ TryFindException< T >()

static bool AnalyzeReTesting.Utilities.AssertApi.TryFindException< T > ( Exception  ex,
out T  foundException 
)
inlinestatic

Convert the current exception to the specified Exception type T , or check if any InnerExceptions match that type.

Template Parameters
TThe Exception type to locate.
Parameters
exThe exception to traverse.
foundExceptionThe exception found with the specified type.
Returns
True if an exception matching the specified type was found.
Type Constraints
T :Exception 

Definition at line 35 of file AssertApi.cs.

Member Data Documentation

◆ DEFAULT_DOUBLE_EQUIVALENCE_TOLERANCE

const double AnalyzeReTesting.Utilities.AssertApi.DEFAULT_DOUBLE_EQUIVALENCE_TOLERANCE = 1E-14
static

Definition at line 27 of file AssertApi.cs.


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