C# Client Library
A C# Client Library for the AnalyzeRe REST API
|
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. | |
Generic Unit test implementations that will test REST methods on arbitrary resources.
Definition at line 25 of file GenericTest.cs.
|
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.
|
inlinestatic |
T | : | IAPIResource |
Definition at line 198 of file GenericTest.cs.
|
inlinestatic |
Ensures that a GET can be done on the collection.
T | The type of resource to test retrieval of. |
collection_source | A IResourceCollection to use to test retrieval. |
T | : | IAPIResource |
Definition at line 31 of file GenericTest.cs.
|
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.
T | The type of resource to test retrieval of. |
collection_source | A IResourceCollection to use to test retrieval. |
reflection | The Reflection instance used to generate random resources. |
offset | The offset to use when retrieving resources (default 0) |
limit | The maximum number of resources to retrieve during the collection get (default 100). |
additionalParameters | Additional parameters to use on GET. |
additionalActions | Additional validation actions to perform on the result. |
timeout | The timeout to use. |
T | : | IAPIResource |
Definition at line 102 of file GenericTest.cs.
|
inlinestatic |
Verify that getting the specified resource succeeds (after posting it).
existingResource | A valid resource that either has already or been posted or can be posted. |
T | : | IAPIResource |
Definition at line 189 of file GenericTest.cs.
Create an instance of the specified resource.
T | : | IAPIResource |
Definition at line 554 of file GenericTest.cs.
|
inlinestatic |
A Mini test suite that discovers all types that derive from the specified base resource type, and posts a random one of each.
reflection | The Reflection instance used to generate random resources. |
T | : | IAPIResource |
Definition at line 345 of file GenericTest.cs.
|
static |
Verify that posting the specified resource fails with a HttpStatusCode.BadRequest status code.
invalidToPost | An invalid resource that cannot be posted. |
T | : | IAPIResource | |
T | : | POST_InvalidResource_Fails | |
T | : | invalidToPost | |
T | : | AssertApi.ApiExceptionTest | |
T | : | HttpStatusCode.BadRequest |
|
inlinestatic |
Verify that posting the specified resource fails.
invalidToPost | An invalid resource that cannot be posted. |
exceptionTest | A method that verifies that the exception thrown is what is expected. |
T | : | IAPIResource | |
TException | : | Exception |
Definition at line 436 of file GenericTest.cs.
|
inlinestatic |
Verify that posting the specified resource with data fails.
toPost | A valid resource that can be posted. |
data | The data to post. |
T | : | IAPIResource_WithDataEndpoint |
Definition at line 447 of file GenericTest.cs.
|
inlinestatic |
Verify that posting the specified resource with data fails.
toPost | A valid resource that can be posted. |
data | The data to post. |
exceptionTest | A method that verifies that the exception thrown is what is expected. |
T | : | IAPIResource_WithDataEndpoint | |
TException | : | Exception |
Definition at line 459 of file GenericTest.cs.
|
inlinestatic |
Post a valid resource under the assumption that it will succeed, then perform an action on the resulting posted object, then clean up.
T | The type of resource to post. |
toPost | The resource to post. |
toExecute | The action to execute on the posted object after posting and before cleaning up. |
T | : | IAPIResource |
Definition at line 402 of file GenericTest.cs.
Verify that posting the specified resource succeeds.
toPost | A valid resource that can be posted. |
T | : | IAPIResource |
Definition at line 359 of file GenericTest.cs.
|
inlinestatic |
Verify that posting the specified resource succeeds.
toPost | A valid resource that can be posted. |
data | The data to post. |
T | : | IAPIResource_WithDataEndpoint |
Definition at line 376 of file GenericTest.cs.
|
inlinestatic |
Post a valid resource under the assumption that it will succeed, then perform an action on the resulting posted object, then clean up.
T | The type of resource to post. |
toPost | The resource to post. |
data | The data to upload following the post. |
toExecute | The action to execute on the posted object after posting and before cleaning up. |
T | : | IAPIResource_WithDataEndpoint |
Definition at line 417 of file GenericTest.cs.
|
inlinestatic |
Asserts that executing a PUT on the specified resource fails.
T | The type of resource/ |
TException | The type of error that should be thrown. |
toPut | The resource to perform a PUT request on. |
exceptionTest | A optional action (presumably an assertion) to execute on the returned exception, presuming it was of the expected type. |
T | : | IAPIResource | |
TException | : | Exception |
Definition at line 541 of file GenericTest.cs.
|
inlinestatic |
Try to generate and POSt a random new resource on the server of the specified type.
T | The type to cast the returned resource to. |
subtype | The type of resource to generate. |
reflection | The Reflection instance used to generate random resources. |
attempts | When 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. |
T | : | IAPIResource |
Definition at line 63 of file GenericTest.cs.
|
inlinestatic |
Performs a data upload against the specified resource. Returns the result of a fresh GET on the data once the upload is complete.
T | The type of the IAPIResource_WithDataEndpoint. |
resource | The resource instance that has been posted, but no data uploaded yet. |
data | The data to upload. |
T | : | IAPIResource_WithDataEndpoint |
Definition at line 387 of file GenericTest.cs.