Class rpycUnitTests
The following tests may seem a bit complicated, but since we need to
test with other processes, this takes time and thus we need to
implement waiting methods. We leverage the UnityTest attribute
for our waits. Contrary to regular C#, we can nest yield return calls
and get the "intuitive" behaviour.
Inheritance
rpycUnitTests
Syntax
public class rpycUnitTests
Properties
Declaration
public static bool ClientContactFlag { get; set; }
Property Value
Methods
AsyncClientToServerCall()
Note: nUnit should support asynchronous tests, but since unity is on a custom version
there is something that prevents it from playing nice. "Await" manually on it
Declaration
public IEnumerator AsyncClientToServerCall()
Returns
CallServiceWithoutClient()
Calls a service but there's no client.
Verify it makes a reasonable error.
Declaration
public void CallServiceWithoutClient()
CoroutineClientToServerCall()
Tests that we can:
- spawn a client
- call a service on it asynchronously and have it play well with a coroutine
- have the client call into Unity to manipulate the scene (create and rename an object)
Declaration
public IEnumerator CoroutineClientToServerCall()
Returns
RestartServer(String)
Stops the server, then restart it, and wait for client to reconnect.
Declaration
public IEnumerator RestartServer(string clientID = "")
Parameters
| Type |
Name |
Description |
| String |
clientID |
Client ID used to see if the reconnected
client is the one we expect. Only used if the shouldReconnect
parameter is true
|
Returns
SetUp()
Declaration
StartAndStopServer()
Tests that we can:
- spawn a client
- call a service on it and get a result
- shut down the server inviting a reconnect
- reopen the server
- find the same client and have it return proof that it knows the server shut down
Declaration
public IEnumerator StartAndStopServer()
Returns
StartClient(String, String)
Starts a client (and the server if needed). Use as an IEnumerable or a coroutine
Declaration
public IEnumerator StartClient(string clientID, string clientName = "com.unity.scripting.python.tests.rpyc")
Parameters
| Type |
Name |
Description |
| String |
clientID |
Client's second name. Specified by the caller
|
| String |
clientName |
|
Returns
TearDown()
Declaration
TestBaseClient()
Declaration
public IEnumerator TestBaseClient()
Returns
TestClientWithoutServices()
Declaration
public IEnumerator TestClientWithoutServices()
Returns
TestKillClient()
Declaration
public IEnumerator TestKillClient()
Returns
TestNewerClient()
Declaration
public IEnumerator TestNewerClient()
Returns
TestServedExposedFunctions()
Declaration
public IEnumerator TestServedExposedFunctions()
Returns
TestTimeout()
Declaration
public IEnumerator TestTimeout()
Returns
UT1449StopServerWhileClientIsBusy()
Declaration
public IEnumerator UT1449StopServerWhileClientIsBusy()
Returns
WaitForSecondsDuringUnityTest(Double, Func<Boolean>)
Because UnityTests can only yield return null (or an IEnumerator
yield returning null), we cannot use Unity's WaitForSeconds. Make
our own version.
If a condition function was given, if the condition never evaluated
to True during the loop, raises a Assert.Fail
Declaration
public IEnumerator WaitForSecondsDuringUnityTest(double waitTime, Func<bool> condition = null)
Parameters
| Type |
Name |
Description |
| Double |
waitTime |
The interval of time to wait for, in seconds.
|
| Func<Boolean> |
condition |
A function returning a boolean. If the function returns true, exit early.
|
Returns