Class TryCatchTests
Inherited Members
Namespace: Unity.VisualScripting.Tests.Units.Control
Assembly: solution.dll
Syntax
public class TryCatchTests : BaseGraphExecutionTests
Methods
TestCanNotDefineWithInvalidExceptionType()
canDefine is false if exceptionType is not an Exception.
Declaration
public void TestCanNotDefineWithInvalidExceptionType()
TestCatchInvokedIfTryFlowThrows()
Test that the catch flow is invoked if the try flow does throw.
Declaration
public void TestCatchInvokedIfTryFlowThrows()
TestCatchNotInvokedIfTryFlowDoesntThrow()
Test that the catch flow is not invoked if the try flow doesn't throw.
Declaration
public void TestCatchNotInvokedIfTryFlowDoesntThrow()
TestCatchingCustomException()
Test that we can catch a custom exception.
Declaration
public void TestCatchingCustomException()
TestExceptionCaughtByInnermostHandler()
If there are nested handlers, and the inner one does catch a type of exception, it is not propagated to the outer one.
Declaration
public void TestExceptionCaughtByInnermostHandler()
TestExceptionOutputIsRetained()
A TryCatch node retains its caught exception past the catch block and into the finally block, and even retains it if it is invoked again, though there was no exception this second time.
Declaration
public void TestExceptionOutputIsRetained()
Remarks
This sets up a graph with a Sequence node that invokes a TryCatch node twice. The first time it is invoked, the "try flow" throws an exception. This exception is then present in the "exception" ValueOutput as the catch and finally flows are invoked.
The second time the TryCatch node is invoked, its try block does not throw an exception, and thus the catch flow is not invoked. The finally flow is invoked, and as it is the exception from the first time the try flow was invoked is still available from the exception ValueOutput.
TestFinallyInvoked(bool)
Check that the finally flow is invoked both when an exception is thrown and when one isn't.
Declaration
public void TestFinallyInvoked(bool throwException)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | throwException |
TestNestedExceptionHandlers()
If there are nested handlers, and the inner one doesn't catch a type of exception, it is propagated to the outer one.
Declaration
public void TestNestedExceptionHandlers()
TestNonMatchingExceptionThrown()
Test what happens when the exception thrown is not the type we want to catch.
Declaration
public void TestNonMatchingExceptionThrown()