2using System.Diagnostics;
10using Microsoft.VisualStudio.TestTools.UnitTesting;
26 Assert.Inconclusive(
"RUN_OFFLINE = true");
27 bool serverIsClean =
true;
33 if (count == 0)
continue;
34 string alert =
"Warning: The server has not been properly cleaned up. " +
36 " resource collection.";
39 Debug.WriteLine(alert);
40 serverIsClean =
false;
43 Assert.AreEqual(0, count, alert);
48 Debug.WriteLine(
"Error: Exception during CheckServerIsClean.\n" +
49 " Exception Details: " + e);
50 if (!ignoreExceptions)
63 public static bool ForceCleanServer(
bool ignoreExceptions =
false,
int? timeout =
null)
66 Assert.Inconclusive(
"RUN_OFFLINE = true");
67 DateTime start = DateTime.UtcNow;
79 string alert =
"Cleanup of the server failed after " +
80 (DateTime.UtcNow - start).TotalSeconds +
" seconds.\n" +
81 " Exception Details: " + e;
82 Debug.WriteLine(
"Warning: " + alert);
83 if (!ignoreExceptions)
97 Assert.Inconclusive(
"RUN_OFFLINE = true");
98 if (item ==
null)
return true;
106 Debug.WriteLine(
"Warning: Cannot delete the " + item.GetType().NiceTypeName() +
107 " with id: " + item.
id +
".\n Exception Details: " + e);
Exposes sample resource objects, with built-in methods for injecting dependencies.
static List< Type > GetAPIResourceTypes()
A list of base "production" resource types on the server, (e.g. each with their own collection) used ...
Utilities for cleaning up the server.
static bool ForceCleanServer(bool ignoreExceptions=false, int? timeout=null)
Invoke the DELETE method on the root of the server. Will wait for the DELETE to complete successfully...
static bool CheckServerIsClean(bool ignoreExceptions=false)
Check all known server endpoints and determine whether there are any resources on the server.
static bool TryDelete_Silent(IAPIResource item)
Attempt to delete the resource, but throw no exceptions if it cannot be deleted.
Retrieve settings from environment variables if they exist, or the project settings file otherwise.
static bool RUN_OFFLINE
Controls whether tests that normally require a connection to the server should be allowed to try to r...
static int DELETE_TIMEOUT
Amount of time to wait for DELETE to complete (in milliseconds).
static bool RESOURCE_DELETE_SUPPORTED
Indicates whether the server currently supports the DELETE method on resources.
API methods / requests made available to the user.
static ICollectionResponse< IAPIResource > GetResourceList(Type resourceType, IEnumerable< Parameter > requestParameters=null, string collectionNameOverride=null, int? timeout=null)
Get a collection of resources from the server.
static object RequestAndParse(Type deserializeType, string resource, Method method, IEnumerable< Parameter > requestParameters=null, int? timeout=null)
Perform a REST request on the server and serializes the response to the desired run-time type.
static string GetCollectionName(Type requestType)
Gets the collection name for the given APIResource type, whether it's instantiable or not.
Determines the behaviour of the API when automatically retrying a request whose result is not yet rea...
Interface for Base class used by all resources.
string id
The resource's unique identifier. It will be used in the request URL when requesting the resource fro...