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

Generic Unit test implementations that will test REST methods on arbitrary resources. More...

Static Public Member Functions

static void ExecuteWithConsoleErrorLogging (Action action, Func< string > additionalContext=null)
 Wraps the call to the action with a try/catch that doesn't handle the exception, just logs some useful information.
 
static void GET_AllPropertiesRecognized< T > (T existingResource)
 
static void GET_Collection< T > (IResourceCollection< T > collection_source)
 Ensures that a GET can be done on the collection.
 
static void GET_Collection_AllSubtypes< T > (IResourceCollection< T > collection_source, Reflection reflection, long offset=0, long limit=100, RequestParameters additionalParameters=null, Action< ICollectionResponse< T > > additionalActions=null, int? timeout=null)
 A Mini test suite that discovers all types that derive from the specified base resource type, and posts a random one of each. The test then verifies that it is possible to do a get on the collection with one of each possible sub-type in the list.
 
static void GET_ExistingResource_Succeeds< T > (T existingResource)
 Verify that getting the specified resource succeeds (after posting it).
 
static T Mock< T > (string id)
 Create an instance of the specified resource.
 
static void POST_AllSubtypes_Succeeds< T > (Reflection reflection)
 A Mini test suite that discovers all types that derive from the specified base resource type, and posts a random one of each.
 
static void POST_InvalidResource_Fails< T > (T invalidToPost)
 Verify that posting the specified resource fails with a HttpStatusCode.BadRequest status code.
 
static void POST_InvalidResource_Fails< T, TException > (T invalidToPost, Action< TException > exceptionTest)
 Verify that posting the specified resource fails.
 
static void POST_InvalidResourceWithData_Fails< T > (T toPost, string data)
 Verify that posting the specified resource with data fails.
 
static void POST_InvalidResourceWithData_Fails< T, TException > (T toPost, string data, Action< TException > exceptionTest)
 Verify that posting the specified resource with data fails.
 
static T POST_ThenDoAction< T > (T toPost, Action< T > toExecute)
 Post a valid resource under the assumption that it will succeed, then perform an action on the resulting posted object, then clean up.
 
static T POST_ValidResource< T > (T toPost)
 Verify that posting the specified resource succeeds.
 
static T POST_ValidResourceWithData< T > (T toPost, string data)
 Verify that posting the specified resource succeeds.
 
static T POST_WithData_ThenDoAction< T > (T toPost, string data, Action< T > toExecute)
 Post a valid resource under the assumption that it will succeed, then perform an action on the resulting posted object, then clean up.
 
static void PUT_Fails< T, TException > (T toPut, Action< TException > exceptionTest=null)
 Asserts that executing a PUT on the specified resource fails.
 
static T Try_POST_Random_Resource< T > (Type subtype, Reflection reflection, int attempts=3)
 Try to generate and POSt a random new resource on the server of the specified type.
 
static T UploadData< T > (T resource, string data)
 Performs a data upload against the specified resource. Returns the result of a fresh GET on the data once the upload is complete.
 

Detailed Description

Generic Unit test implementations that will test REST methods on arbitrary resources.

Definition at line 25 of file GenericTest.cs.

Member Function Documentation

◆ ExecuteWithConsoleErrorLogging()

static void AnalyzeReTesting.Utilities.GenericTest.ExecuteWithConsoleErrorLogging ( Action  action,
Func< string additionalContext = null 
)
inlinestatic

Wraps the call to the action with a try/catch that doesn't handle the exception, just logs some useful information.

Definition at line 564 of file GenericTest.cs.

◆ GET_AllPropertiesRecognized< T >()

static void AnalyzeReTesting.Utilities.GenericTest.GET_AllPropertiesRecognized< T > ( T  existingResource)
inlinestatic
Type Constraints
T :IAPIResource 

Definition at line 198 of file GenericTest.cs.

◆ GET_Collection< T >()

static void AnalyzeReTesting.Utilities.GenericTest.GET_Collection< T > ( IResourceCollection< T collection_source)
inlinestatic

Ensures that a GET can be done on the collection.

Template Parameters
TThe type of resource to test retrieval of.
Parameters
collection_sourceA IResourceCollection to use to test retrieval.
Type Constraints
T :IAPIResource 

Definition at line 31 of file GenericTest.cs.

◆ GET_Collection_AllSubtypes< T >()

static void AnalyzeReTesting.Utilities.GenericTest.GET_Collection_AllSubtypes< T > ( IResourceCollection< T collection_source,
Reflection  reflection,
long  offset = 0,
long  limit = 100,
RequestParameters  additionalParameters = null,
Action< ICollectionResponse< T > >  additionalActions = null,
int timeout = null 
)
inlinestatic

A Mini test suite that discovers all types that derive from the specified base resource type, and posts a random one of each. The test then verifies that it is possible to do a get on the collection with one of each possible sub-type in the list.

Template Parameters
TThe type of resource to test retrieval of.
Parameters
collection_sourceA IResourceCollection to use to test retrieval.
reflectionThe Reflection instance used to generate random resources.
offsetThe offset to use when retrieving resources (default 0)
limitThe maximum number of resources to retrieve during the collection get (default 100).
additionalParametersAdditional parameters to use on GET.
additionalActionsAdditional validation actions to perform on the result.
timeoutThe timeout to use.
Type Constraints
T :IAPIResource 

Definition at line 102 of file GenericTest.cs.

◆ GET_ExistingResource_Succeeds< T >()

static void AnalyzeReTesting.Utilities.GenericTest.GET_ExistingResource_Succeeds< T > ( T  existingResource)
inlinestatic

Verify that getting the specified resource succeeds (after posting it).

Parameters
existingResourceA valid resource that either has already or been posted or can be posted.
Type Constraints
T :IAPIResource 

Definition at line 189 of file GenericTest.cs.

◆ Mock< T >()

static T AnalyzeReTesting.Utilities.GenericTest.Mock< T > ( string  id)
inlinestatic

Create an instance of the specified resource.

Type Constraints
T :IAPIResource 

Definition at line 554 of file GenericTest.cs.

◆ POST_AllSubtypes_Succeeds< T >()

static void AnalyzeReTesting.Utilities.GenericTest.POST_AllSubtypes_Succeeds< T > ( Reflection  reflection)
inlinestatic

A Mini test suite that discovers all types that derive from the specified base resource type, and posts a random one of each.

Parameters
reflectionThe Reflection instance used to generate random resources.
Type Constraints
T :IAPIResource 

Definition at line 345 of file GenericTest.cs.

◆ POST_InvalidResource_Fails< T >()

static void AnalyzeReTesting.Utilities.GenericTest.POST_InvalidResource_Fails< T > ( T  invalidToPost)
static

Verify that posting the specified resource fails with a HttpStatusCode.BadRequest status code.

Parameters
invalidToPostAn invalid resource that cannot be posted.
Type Constraints
T :IAPIResource 
T :POST_InvalidResource_Fails 
T :invalidToPost 
T :AssertApi.ApiExceptionTest 
T :HttpStatusCode.BadRequest 

◆ POST_InvalidResource_Fails< T, TException >()

static void AnalyzeReTesting.Utilities.GenericTest.POST_InvalidResource_Fails< T, TException > ( T  invalidToPost,
Action< TException exceptionTest 
)
inlinestatic

Verify that posting the specified resource fails.

Parameters
invalidToPostAn invalid resource that cannot be posted.
exceptionTestA method that verifies that the exception thrown is what is expected.
Type Constraints
T :IAPIResource 
TException :Exception 

Definition at line 436 of file GenericTest.cs.

◆ POST_InvalidResourceWithData_Fails< T >()

static void AnalyzeReTesting.Utilities.GenericTest.POST_InvalidResourceWithData_Fails< T > ( T  toPost,
string  data 
)
inlinestatic

Verify that posting the specified resource with data fails.

Parameters
toPostA valid resource that can be posted.
dataThe data to post.
Type Constraints
T :IAPIResource_WithDataEndpoint 

Definition at line 447 of file GenericTest.cs.

◆ POST_InvalidResourceWithData_Fails< T, TException >()

static void AnalyzeReTesting.Utilities.GenericTest.POST_InvalidResourceWithData_Fails< T, TException > ( T  toPost,
string  data,
Action< TException exceptionTest 
)
inlinestatic

Verify that posting the specified resource with data fails.

Parameters
toPostA valid resource that can be posted.
dataThe data to post.
exceptionTestA method that verifies that the exception thrown is what is expected.
Type Constraints
T :IAPIResource_WithDataEndpoint 
TException :Exception 

Definition at line 459 of file GenericTest.cs.

◆ POST_ThenDoAction< T >()

static T AnalyzeReTesting.Utilities.GenericTest.POST_ThenDoAction< T > ( T  toPost,
Action< T toExecute 
)
inlinestatic

Post a valid resource under the assumption that it will succeed, then perform an action on the resulting posted object, then clean up.

Template Parameters
TThe type of resource to post.
Parameters
toPostThe resource to post.
toExecuteThe action to execute on the posted object after posting and before cleaning up.
Type Constraints
T :IAPIResource 

Definition at line 402 of file GenericTest.cs.

◆ POST_ValidResource< T >()

static T AnalyzeReTesting.Utilities.GenericTest.POST_ValidResource< T > ( T  toPost)
inlinestatic

Verify that posting the specified resource succeeds.

Parameters
toPostA valid resource that can be posted.
Type Constraints
T :IAPIResource 

Definition at line 359 of file GenericTest.cs.

◆ POST_ValidResourceWithData< T >()

static T AnalyzeReTesting.Utilities.GenericTest.POST_ValidResourceWithData< T > ( T  toPost,
string  data 
)
inlinestatic

Verify that posting the specified resource succeeds.

Parameters
toPostA valid resource that can be posted.
dataThe data to post.
Type Constraints
T :IAPIResource_WithDataEndpoint 

Definition at line 376 of file GenericTest.cs.

◆ POST_WithData_ThenDoAction< T >()

static T AnalyzeReTesting.Utilities.GenericTest.POST_WithData_ThenDoAction< T > ( T  toPost,
string  data,
Action< T toExecute 
)
inlinestatic

Post a valid resource under the assumption that it will succeed, then perform an action on the resulting posted object, then clean up.

Template Parameters
TThe type of resource to post.
Parameters
toPostThe resource to post.
dataThe data to upload following the post.
toExecuteThe action to execute on the posted object after posting and before cleaning up.
Type Constraints
T :IAPIResource_WithDataEndpoint 

Definition at line 417 of file GenericTest.cs.

◆ PUT_Fails< T, TException >()

static void AnalyzeReTesting.Utilities.GenericTest.PUT_Fails< T, TException > ( T  toPut,
Action< TException exceptionTest = null 
)
inlinestatic

Asserts that executing a PUT on the specified resource fails.

Template Parameters
TThe type of resource/
TExceptionThe type of error that should be thrown.
Parameters
toPutThe resource to perform a PUT request on.
exceptionTestA optional action (presumably an assertion) to execute on the returned exception, presuming it was of the expected type.
Type Constraints
T :IAPIResource 
TException :Exception 

Definition at line 541 of file GenericTest.cs.

◆ Try_POST_Random_Resource< T >()

static T AnalyzeReTesting.Utilities.GenericTest.Try_POST_Random_Resource< T > ( Type  subtype,
Reflection  reflection,
int  attempts = 3 
)
inlinestatic

Try to generate and POSt a random new resource on the server of the specified type.

Template Parameters
TThe type to cast the returned resource to.
Parameters
subtypeThe type of resource to generate.
reflectionThe Reflection instance used to generate random resources.
attemptsWhen randomly generating resources, there are a variety of scenarios, some more likely than others, where the randomly generated resource will fail some validation rule on the server side. This is the number of failed attempts to permit and retry before treating the POST of this type as a failure.
Returns
The POSTed resource.
Type Constraints
T :IAPIResource 

Definition at line 63 of file GenericTest.cs.

◆ UploadData< T >()

static T AnalyzeReTesting.Utilities.GenericTest.UploadData< T > ( T  resource,
string  data 
)
inlinestatic

Performs a data upload against the specified resource. Returns the result of a fresh GET on the data once the upload is complete.

Template Parameters
TThe type of the IAPIResource_WithDataEndpoint.
Parameters
resourceThe resource instance that has been posted, but no data uploaded yet.
dataThe data to upload.
Type Constraints
T :IAPIResource_WithDataEndpoint 

Definition at line 387 of file GenericTest.cs.


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