C# Client Library
A C# Client Library for the AnalyzeRe REST API
|
Contains static helper methods for testing IAPIResourceView instances. More...
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 Action< ArgumentOutOfRangeException > | ProbabilityError (double min, double max) |
Test for a client-side ArgumentOutOfRangeException linked to a bad probability. | |
static void | Test_IAPIResourceView_Metrics_MixedLossTypes (T posted, Perspective leastGranularPerspective=null) |
static void | TestMetricsRetrievable< T > (T view) |
Asserts that the posted view's metrics can be retrieved without error. | |
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. | |
static readonly PollingOptions | SimulationPolling |
Settings used to ensure simulation requests are retried frequently and timeout after a reasonable amount of time in a test setting. | |
Protected Member Functions | |
TestSuite_APIResourceView () | |
void | AddCommonTestCleanupAction (Action action) |
void | AddCommonTestInitializeAction (Action action) |
void | Test_IAPIResourceView_Action_Fails< TException > (Action< T > action, Action< TException > exceptionTest) |
void | Test_IAPIResourceView_Action_Succeeds (Action< T > action) |
void | Test_IAPIResourceView_GET_ExceedanceProbability_Succeeds (double threshold, ExceedanceProbabilityOptions options=null) |
void | TestResourceDeleteHelper (T toDelete, bool isDeleteAllowed) |
void | VerifyBackAllocationSuccess (BackAllocations result) |
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. | |
static PollingOptions | SimulationPolling [get] |
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. | |
virtual T | TestResource [get] |
The resource used for all unit tests that require a valid prepared but unPOSTed resource. | |
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. | |
Contains static helper methods for testing IAPIResourceView instances.
T | : | IAPIResourceView |
Definition at line 69 of file Test_APIResourceView.cs.
|
inlineprotected |
Definition at line 81 of file Test_APIResourceView.cs.
|
inlineprotectedinherited |
Definition at line 80 of file BaseTestSuite.cs.
|
inlineprotectedinherited |
Definition at line 75 of file BaseTestSuite.cs.
|
virtual |
Deriving classes can optionally override this function to perform additional validation on every successfully POSTed resource.
Reimplemented from AnalyzeReTesting.Base.BaseResourceTestSuite< T >.
|
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.
|
inlinestatic |
Test for a client-side ArgumentOutOfRangeException linked to a bad probability.
Definition at line 182 of file Test_APIResourceView.cs.
|
inlineprotected |
TException | : | Exception |
Definition at line 134 of file Test_APIResourceView.cs.
|
inlineprotected |
Definition at line 130 of file Test_APIResourceView.cs.
|
inlinevirtual |
Reimplemented in AnalyzeReTesting.Tests.Model.TestSuite_LayerView< T >, and AnalyzeReTesting.Tests.Model.TestSuite_PortfolioView.
Definition at line 1672 of file Test_APIResourceView.cs.
|
inlinevirtual |
Reimplemented in AnalyzeReTesting.Tests.Model.TestSuite_LayerView< T >.
Definition at line 1683 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1388 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1424 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1305 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1416 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1357 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1364 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1275 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1297 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1380 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1372 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1195 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1600 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1612 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1624 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1643 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1527 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1346 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1335 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1208 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1221 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1408 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1481 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1452 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1434 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1398 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1501 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 890 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 904 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 936 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 989 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1044 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1013 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 928 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 920 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1006 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 996 of file Test_APIResourceView.cs.
|
inlineprotected |
Definition at line 816 of file Test_APIResourceView.cs.
|
inlinevirtual |
Test numerous valid threshold values and ensure they succeed.
Definition at line 873 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 974 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 981 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1023 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 413 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1248 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 501 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 403 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 365 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 371 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 322 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 334 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 379 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 475 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 357 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 349 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 307 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 296 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 396 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 386 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 439 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 460 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 426 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 711 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 724 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 701 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 663 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 669 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 619 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 632 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 798 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 677 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 774 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 655 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 647 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 581 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 593 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 694 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 684 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 737 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 757 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1708 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1750 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1728 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 1693 of file Test_APIResourceView.cs.
|
inlinestatic |
Definition at line 141 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 93 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 103 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 108 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 98 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 116 of file Test_APIResourceView.cs.
|
inlinevirtual |
Definition at line 121 of file Test_APIResourceView.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 |
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 |
Verifies that it is okay to post an object with an ID that already exists on the server, even if the object is identical to the one already on the server. This is tested by posting a valid resource, and then rePOSTing the returned resource again (including the id property).
TODO: This test is almost meaningless because the JSON serializer used does not even include the ID in the request JSON (as it is a server-generated property). As such, this does not end up testing the behaviour of the server, so much as the behaviour of the client library.
Reimplemented in AnalyzeReTesting.Tests.Model.TestSuite_Layer_Unsaveable< T >, and AnalyzeReTesting.Tests.Model.TestSuite_OptimizationFunction< T >.
Definition at line 142 of file BaseResourceTestSuite.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.
|
virtualinherited |
|
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.
|
inlinestatic |
Asserts that the posted view's metrics can be retrieved without error.
Re-throws any exception that may have been thrown while polling for metrics.
T | : | IAPIResourceView |
Definition at line 41 of file Test_APIResourceView.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.
|
inlineprotected |
Definition at line 1662 of file Test_APIResourceView.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.
|
static |
Settings used to ensure simulation requests are retried frequently and timeout after a reasonable amount of time in a test setting.
Definition at line 34 of file Test_APIResourceView.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.
|
staticget |
Definition at line 79 of file Test_APIResourceView.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.
|
getprotectedinherited |
The resource used for all unit tests that require a valid prepared but unPOSTed resource.
Definition at line 34 of file BaseResourceTestSuite.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.