C# Client Library
A C# Client Library for the AnalyzeRe REST API
|
Public Member Functions | |
virtual void | AdditionalValidResourceTests (T posted) |
Deriving classes can optionally override this function to perform additional validation on every successfully POSTed resource. | |
void | BaseTest_Cleanup () |
void | BaseTest_Initialize () |
void | POST_Attribute_Null< TProperty > (Expression< Func< T, TProperty > > PropertyExpression, bool? shouldSucceed=null) |
Post a resource with the specified property set to null. | |
void | POST_ListAttribute_Duplicates< TItem, TValue > (Expression< Func< T, ICollection< TItem > > > PropertyExpression, TValue valueToDuplicate, bool shouldSucceed) |
void | POST_ListAttribute_Empty< TItem > (Expression< Func< T, ICollection< TItem > > > PropertyExpression, bool? shouldSucceed=null) |
void | POST_Reference_EmptyStringId< TRefType > (Expression< Func< T, IReference< TRefType > > > PropertyExpression) |
Posts a reference with a empty string Id and verifies the correct error is returned. | |
void | POST_Reference_NonExistantId< TRefType > (Expression< Func< T, IReference< TRefType > > > PropertyExpression) |
Posts a reference with a non-existent Id and verifies the correct error is returned. | |
void | POST_Reference_NullId< TRefType > (Expression< Func< T, IReference< TRefType > > > PropertyExpression) |
Posts a reference with a null Id and verifies the correct error is returned. | |
void | POST_ReferenceList_NonExistantId< TRefType > (Expression< Func< T, ICollection< IReference< TRefType > > > > PropertyExpression) |
Posts a reference list with a non-existent Id and verifies the correct error is returned. | |
void | POST_StringAttribute_Empty (Expression< Func< T, string > > PropertyExpression, bool? shouldSucceed=null) |
Post a resource with the specified string set to an empty string. | |
virtual void | POST_ThenDoAction (T validToPost, 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. | |
virtual void | POST_WithValue< TProperty > (Expression< Func< T, TProperty > > PropertyExpression, TProperty newValue, bool shouldSucceed) |
Modify a property of the test resource, and then test it. | |
virtual void | Test_OptimizationFunction_POST_Name_Blank () |
virtual void | Test_OptimizationFunction_POST_Name_Null () |
virtual void | Test_OptimizationFunction_POST_Src_Blank () |
virtual void | Test_OptimizationFunction_POST_Src_Null () |
virtual void | Test_Reflection_ChangePropertyValueRandomly () |
Test reflection utilities meant to randomly change property values in a way that would pass server validation. | |
virtual void | Test_Resource_DeepCopy () |
Test that any resource can be "Deep Copied", a slower copy method that creates a new duplicate instance of a resource type by serializing it and then deserializing the resulting JSON to a new resource. | |
virtual void | Test_Resource_DELETE () |
virtual void | Test_Resource_DELETE_NonExistant () |
virtual void | Test_Resource_GET_AllPropertiesRecognized () |
virtual void | Test_Resource_GET_Existing () |
virtual void | Test_Resource_GET_Existing_ResolveReferences () |
IStoredAPIResource collections support reference resolution. | |
virtual void | Test_Resource_GET_FromBatch () |
Test that resources of this type can be retrieved using the collection batch-get feature. | |
virtual void | Test_Resource_GetCollectionName () |
Verify that all runtime types expose their collection name. | |
virtual void | Test_Resource_OfflineRandomGeneration () |
Test reflection utilities meant to randomly change property values (used for testing comprarer coverage). | |
virtual void | Test_Resource_OnlineRandomGeneration () |
Test reflection utilities meant to randomly change property values in a way that would pass server validation. | |
virtual void | Test_Resource_POST_CreatedAndModified () |
virtual void | Test_Resource_POST_Description_Blank () |
virtual void | Test_Resource_POST_Description_Null () |
override void | Test_Resource_POST_ExistingId () |
virtual void | Test_Resource_POST_FieldsIdOnly () |
Test that a user can post a resource and get back only the id using the omit query parameter. | |
virtual void | Test_Resource_POST_Id_Ignored () |
No matter what string we set the Id property to, POST should succeed because the Id of the posted resource should be ignored by the server. | |
virtual void | Test_Resource_POST_Metadata_Empty () |
override void | Test_Resource_POST_Metadata_InvalidValues () |
override void | Test_Resource_POST_MetaData_MixedTypes () |
virtual void | Test_Resource_POST_Metadata_Null () |
virtual void | Test_Resource_POST_Valid () |
virtual void | Test_Resource_PUT_NotAllowed () |
override void | Test_Resource_Search () |
All resources should support searching in a few fundamental ways. | |
virtual void | Test_Resource_ShallowCopy () |
Test that any resource can be "Shallow Copied", which is a quick copy that does a member-wise clone of the object, including private members. | |
virtual void | Test_Resource_TypeReflectionUtilities () |
Test reflection utilities meant to get extract information about runtime types. | |
Static Public Member Functions | |
static void | ApplyConfiguredCredentials () |
Apply the current configured API_URL and API_AuthenticationToken credentials to the static API. | |
static void | CheckConnection () |
Set the Client API Server URL to the configured API_URL. | |
static ICollection< TCollectionItem > | NewCollection< TTarget, TCollectionItem > (Expression< Func< TTarget, ICollection< TCollectionItem > > > propertyExpression, IEnumerable< TCollectionItem > initialItems=null) |
Helper method to create a new collection instance based on the type of the referenced property expression. | |
static void | TestSuiteCleanup () |
Actions to run once when the C# Unit Tests finish. Note: This method will not automatically be inherited and run by tests suites in different assemblies that import this library. You will need to create your own method with the [AssemblyCleanup] attribute that calls this method. | |
static void | TestSuiteInitialize (TestContext context) |
Actions to run once when the C# Unit Tests initialize. Note: This method will not automatically be inherited and run by tests suites in different assemblies that import this library. You will need to create your own method with the [AssemblyInitialize] attribute that calls this method. | |
Static Public Attributes | |
static Reflection | Reflection |
Shared instance of a class for generating random resources. | |
static Samples | Samples |
Shared instance of a class for generating reusable sample resources. | |
Protected Member Functions | |
void | AddCommonTestCleanupAction (Action action) |
void | AddCommonTestInitializeAction (Action action) |
void | TestResourceDeleteHelper (T toDelete, bool isDeleteAllowed) |
Static Protected Member Functions | |
static void | BaseClass_Cleanup (Action action) |
static void | BaseClass_Initialize (TestContext context, Action action) |
static void | TestCopyHelper< TCopy > (TCopy original, Func< TCopy, TCopy > copyAction) |
Properties | |
static IAccessToken | API_AuthenticationToken [get, set] |
Set the AuthenticationToken to supply to the server before every test (if applicable). | |
static string | API_URL [get, set] |
Location of the REST API being tested against. This can be set using the API_URL environment variable. Default is https://localhost:8000/. | |
virtual bool | DELETE_Allowed [get] |
bool | DeletingResourcesBetweenTests [get] |
Determines based on the EnvironmentSettings whether injected resources (such as Samples) are being deleted between each test. | |
TestContext | TestContext [get, set] |
IInjectableResource< T > | TestInjectableResource [get] |
Deriving class must override the TestResourceFactory to return a disposable POSTable test resource that unit tests can consume. | |
override T | TestResource [get] |
virtual T | TestResource_Existing [get] |
The resource used for all unit tests that require a prepared and already posted resource. Warning, there is no protection against the user invoking "PUT" on this resource and changing the state of the resource on the API for everyone. Users that require a resource that it can make modifications to and test saving those modifications must not use this resource. It's here for speed to avoid having to re-POST the same resource multiple times for read-only purposes. | |
bool | TryPost_RandomTestResources = true [get, set] |
Allows deriving classes to disable attempting to POST and validate random resources generated by the Test_Resource_OnlineRandomGeneration base tests method - since some randomly generated resources can wreak havoc on the server. When we have some time to "disaster-proof" the server, we should turn these on and solve the problems encountered. | |
bool | TryRunAdditionalValidResourceTests_RandomTestResources = true [get, set] |
Similar to TryPost_RandomTestResources - but controls whether these resources have the AdditionalValidResourceTests method run on them. | |
T | : | AnalyzeRe.Optimization.Function |
Definition at line 50 of file Test_OptimizationFunctions.cs.
|
inlineprotectedinherited |
Definition at line 80 of file BaseTestSuite.cs.
|
inlineprotectedinherited |
Definition at line 75 of file BaseTestSuite.cs.
|
inlinevirtualinherited |
Deriving classes can optionally override this function to perform additional validation on every successfully POSTed resource.
Reimplemented in AnalyzeReTesting.Base.BaseResourceWithDataTestSuite< T >, AnalyzeReTesting.Tests.Model.TestSuite_APIResourceView< T >, AnalyzeReTesting.Tests.Model.TestSuite_Distribution< T >, AnalyzeReTesting.Tests.Model.TestSuite_Layer< T >, AnalyzeReTesting.Tests.Model.TestSuite_LossFilter< T >, and AnalyzeReTesting.Tests.Model.TestSuite_LossSet< T >.
Definition at line 55 of file BaseResourceTestSuite.cs.
|
inlinestaticinherited |
Apply the current configured API_URL and API_AuthenticationToken credentials to the static API.
Definition at line 226 of file BaseServerAPITestSuite.cs.
|
inlinestaticprotectedinherited |
Definition at line 66 of file BaseTestSuite.cs.
|
inlinestaticprotectedinherited |
Definition at line 56 of file BaseTestSuite.cs.
|
inlineinherited |
Definition at line 46 of file BaseTestSuite.cs.
|
inlineinherited |
Definition at line 35 of file BaseTestSuite.cs.
|
inlinestaticinherited |
Set the Client API Server URL to the configured API_URL.
Definition at line 235 of file BaseServerAPITestSuite.cs.
|
inlinestaticinherited |
Helper method to create a new collection instance based on the type of the referenced property expression.
Definition at line 221 of file BaseResourceTestSuite.cs.
|
inlineinherited |
Post a resource with the specified property set to null.
TProperty | The type of the property being modified. |
PropertyExpression | An expression indicating the TResource property to modify. |
shouldSucceed | (Optional) Whether the action should succeed. Will be automatically determined from the property attributes if not supplied. |
ArgumentException | Can only be used on properties whose default type is null. |
Definition at line 195 of file BaseResourceTestSuite.cs.
|
inlineinherited |
TValue | : | TItem |
Definition at line 247 of file BaseResourceTestSuite.cs.
|
inlineinherited |
Definition at line 237 of file BaseResourceTestSuite.cs.
|
inlineinherited |
Posts a reference with a empty string Id and verifies the correct error is returned.
TRefType | The type of the reference being modified. |
PropertyExpression | An expression indicating the TResource reference property to modify. |
TRefType | : | IAPIResource |
Definition at line 273 of file BaseResourceTestSuite.cs.
|
inlineinherited |
Posts a reference with a non-existent Id and verifies the correct error is returned.
TRefType | The type of the reference being modified. |
PropertyExpression | An expression indicating the TResource reference property to modify. |
TRefType | : | IAPIResource |
Definition at line 283 of file BaseResourceTestSuite.cs.
|
inlineinherited |
Posts a reference with a null Id and verifies the correct error is returned.
TRefType | The type of the reference being modified. |
PropertyExpression | An expression indicating the TResource reference property to modify. |
TRefType | : | IAPIResource |
Definition at line 264 of file BaseResourceTestSuite.cs.
|
inlineinherited |
Posts a reference list with a non-existent Id and verifies the correct error is returned.
TRefType | The type of the reference being modified. |
PropertyExpression | An expression indicating the TResource reference list property to modify. |
TRefType | : | IAPIResource |
Definition at line 294 of file BaseResourceTestSuite.cs.
|
inlineinherited |
Post a resource with the specified string set to an empty string.
PropertyExpression | An expression indicating the TResource property to modify. |
shouldSucceed | (Optional) Whether the action should succeed. Will be automatically determined from the property attributes if not supplied. |
Definition at line 209 of file BaseResourceTestSuite.cs.
|
virtualinherited |
Post a valid resource under the assumption that it will succeed, then perform an action on the resulting posted object, then clean up.
validToPost | The resource to post. |
toExecute | The action to execute on the posted object after posting and before cleaning up. |
Reimplemented in AnalyzeReTesting.Base.BaseResourceWithDataTestSuite< T >.
|
inlinevirtualinherited |
Modify a property of the test resource, and then test it.
TProperty | The type of the property being modified. |
PropertyExpression | An expression indicating the TResource property to modify. |
newValue | The new value to give the property being modified. |
shouldSucceed | Whether the action should succeed. |
Reimplemented in AnalyzeReTesting.Tests.Model.TestSuite_Layer_Unsaveable< T >, and AnalyzeReTesting.Tests.Model.TestSuite_Layer< T >.
Definition at line 178 of file BaseResourceTestSuite.cs.
|
inlinevirtual |
Definition at line 74 of file Test_OptimizationFunctions.cs.
|
inlinevirtual |
Definition at line 69 of file Test_OptimizationFunctions.cs.
|
inlinevirtual |
Definition at line 87 of file Test_OptimizationFunctions.cs.
|
inlinevirtual |
Definition at line 82 of file Test_OptimizationFunctions.cs.
|
inlinevirtualinherited |
Test reflection utilities meant to randomly change property values in a way that would pass server validation.
Definition at line 453 of file BaseResourceTestSuite.cs.
|
inlinevirtualinherited |
Test that any resource can be "Deep Copied", a slower copy method that creates a new duplicate instance of a resource type by serializing it and then deserializing the resulting JSON to a new resource.
Reimplemented in AnalyzeReTesting.Tests.Model.TestSuite_Layer< T >.
Definition at line 360 of file BaseResourceTestSuite.cs.
|
inlinevirtualinherited |
Reimplemented in AnalyzeReTesting.Tests.Model.TestSuite_Layer_Unsaveable< T >.
Definition at line 310 of file BaseResourceTestSuite.cs.
|
inlinevirtualinherited |
Definition at line 319 of file BaseResourceTestSuite.cs.
|
inlinevirtualinherited |
Reimplemented in AnalyzeReTesting.Tests.Model.TestSuite_Layer< T >.
Definition at line 69 of file BaseResourceTestSuite.cs.
|
inlinevirtualinherited |
Reimplemented in AnalyzeReTesting.Tests.Model.TestSuite_Layer_Unsaveable< T >.
Definition at line 61 of file BaseResourceTestSuite.cs.
|
inlinevirtualinherited |
IStoredAPIResource collections support reference resolution.
Reimplemented in AnalyzeReTesting.Tests.Model.TestSuite_Layer_Unsaveable< T >.
Definition at line 29 of file BaseStoredResourceTestSuite.cs.
|
inlinevirtualinherited |
Test that resources of this type can be retrieved using the collection batch-get feature.
Reimplemented in AnalyzeReTesting.Tests.Model.TestSuite_Layer_Unsaveable< T >.
Definition at line 91 of file BaseResourceTestSuite.cs.
|
inlinevirtualinherited |
Verify that all runtime types expose their collection name.
Definition at line 78 of file BaseResourceTestSuite.cs.
|
inlinevirtualinherited |
Test reflection utilities meant to randomly change property values (used for testing comprarer coverage).
Definition at line 409 of file BaseResourceTestSuite.cs.
|
inlinevirtualinherited |
Test reflection utilities meant to randomly change property values in a way that would pass server validation.
Definition at line 436 of file BaseResourceTestSuite.cs.
|
inlinevirtualinherited |
Reimplemented in AnalyzeReTesting.Base.BaseResourceWithDataTestSuite< T >, and AnalyzeReTesting.Tests.Model.TestSuite_Layer_Unsaveable< T >.
Definition at line 57 of file BaseStoredResourceTestSuite.cs.
|
inlinevirtualinherited |
Definition at line 49 of file BaseStoredResourceTestSuite.cs.
|
inlinevirtualinherited |
Definition at line 43 of file BaseStoredResourceTestSuite.cs.
|
inlinevirtual |
Optimization Functions enforce global uniqueness, so this base test must be amended to change the name of the "existing resourcE" being copied.
Reimplemented from AnalyzeReTesting.Base.BaseResourceTestSuite< T >.
Definition at line 61 of file Test_OptimizationFunctions.cs.
|
inlinevirtualinherited |
Test that a user can post a resource and get back only the id using the omit query parameter.
Reimplemented in AnalyzeReTesting.Tests.Model.TestSuite_Layer< T >.
Definition at line 112 of file BaseResourceTestSuite.cs.
|
inlinevirtualinherited |
No matter what string we set the Id property to, POST should succeed because the Id of the posted resource should be ignored by the server.
Reimplemented in AnalyzeReTesting.Tests.Model.TestSuite_Layer_Unsaveable< T >.
Definition at line 127 of file BaseResourceTestSuite.cs.
|
inlinevirtualinherited |
Definition at line 76 of file BaseStoredResourceTestSuite.cs.
|
inlinevirtual |
Reimplemented from AnalyzeReTesting.Base.BaseStoredResourceTestSuite< T >.
Definition at line 102 of file Test_OptimizationFunctions.cs.
|
inlinevirtual |
Reimplemented from AnalyzeReTesting.Base.BaseStoredResourceTestSuite< T >.
Definition at line 96 of file Test_OptimizationFunctions.cs.
|
inlinevirtualinherited |
Definition at line 71 of file BaseStoredResourceTestSuite.cs.
|
virtualinherited |
|
inlinevirtualinherited |
Definition at line 23 of file BaseImmutableResourceTestSuite.cs.
|
inlinevirtual |
All resources should support searching in a few fundamental ways.
Reimplemented from AnalyzeReTesting.Base.BaseStoredResourceTestSuite< T >.
Definition at line 108 of file Test_OptimizationFunctions.cs.
|
inlinevirtualinherited |
Test that any resource can be "Shallow Copied", which is a quick copy that does a member-wise clone of the object, including private members.
Reimplemented in AnalyzeReTesting.Tests.Model.TestSuite_Layer< T >.
Definition at line 348 of file BaseResourceTestSuite.cs.
|
inlinevirtualinherited |
Test reflection utilities meant to get extract information about runtime types.
Definition at line 375 of file BaseResourceTestSuite.cs.
|
inlinestaticprotectedinherited |
TCopy | : | IAPIResource |
Definition at line 488 of file BaseResourceTestSuite.cs.
|
inlineprotectedinherited |
Definition at line 330 of file BaseResourceTestSuite.cs.
|
inlinestaticinherited |
Actions to run once when the C# Unit Tests finish. Note: This method will not automatically be inherited and run by tests suites in different assemblies that import this library. You will need to create your own method with the [AssemblyCleanup] attribute that calls this method.
Definition at line 163 of file BaseServerAPITestSuite.cs.
|
inlinestaticinherited |
Actions to run once when the C# Unit Tests initialize. Note: This method will not automatically be inherited and run by tests suites in different assemblies that import this library. You will need to create your own method with the [AssemblyInitialize] attribute that calls this method.
Definition at line 84 of file BaseServerAPITestSuite.cs.
|
staticinherited |
Shared instance of a class for generating random resources.
Definition at line 18 of file BaseClientTestSuite.cs.
|
staticinherited |
Shared instance of a class for generating reusable sample resources.
Definition at line 15 of file BaseClientTestSuite.cs.
|
staticgetsetinherited |
Set the AuthenticationToken to supply to the server before every test (if applicable).
Definition at line 32 of file BaseServerAPITestSuite.cs.
|
staticgetsetinherited |
Location of the REST API being tested against. This can be set using the API_URL environment variable. Default is https://localhost:8000/.
Definition at line 28 of file BaseServerAPITestSuite.cs.
|
getprotectedinherited |
Definition at line 46 of file BaseResourceTestSuite.cs.
|
getinherited |
Determines based on the EnvironmentSettings whether injected resources (such as Samples) are being deleted between each test.
Definition at line 46 of file BaseServerAPITestSuite.cs.
|
getsetinherited |
Definition at line 20 of file BaseTestSuite.cs.
|
getabstractprotectedinherited |
Deriving class must override the TestResourceFactory to return a disposable POSTable test resource that unit tests can consume.
Definition at line 51 of file BaseResourceTestSuite.cs.
|
getprotected |
Definition at line 56 of file Test_OptimizationFunctions.cs.
|
getprotectedinherited |
The resource used for all unit tests that require a prepared and already posted resource. Warning, there is no protection against the user invoking "PUT" on this resource and changing the state of the resource on the API for everyone. Users that require a resource that it can make modifications to and test saving those modifications must not use this resource. It's here for speed to avoid having to re-POST the same resource multiple times for read-only purposes.
Definition at line 43 of file BaseResourceTestSuite.cs.
|
getsetinherited |
Allows deriving classes to disable attempting to POST and validate random resources generated by the Test_Resource_OnlineRandomGeneration base tests method - since some randomly generated resources can wreak havoc on the server. When we have some time to "disaster-proof" the server, we should turn these on and solve the problems encountered.
Definition at line 426 of file BaseResourceTestSuite.cs.
|
getsetinherited |
Similar to TryPost_RandomTestResources - but controls whether these resources have the AdditionalValidResourceTests method run on them.
Definition at line 431 of file BaseResourceTestSuite.cs.