Drag[en]gine Script Module DragonScript  1.23
Dragengine.TestSystem.TestCaseECBehavior Class Reference

Base class for testing BehaviorElementClass behaviors. More...

Inheritance diagram for Dragengine.TestSystem.TestCaseECBehavior:
Dragengine.TestSystem.TestCase Dragengine.TestSystem.TestCaseECBehaviorPersistency

Classes

class  TestBehaviorElementClass
 Helper class to store the created element aside. More...
 

Public Member Functions

bool getCreateAndAddElementShouldFail ()
 Calling createAndAddElement() on element stub should fail by throwing an exception. More...
 
bool getPreloadShouldFail ()
 Preloading on element class should fail. More...
 
void init ()
 Initialize test. More...
 
TestCaseECBehavior new (String id, UnicodeString name)
 Create test. More...
 
bool run (TestSuite testSuite)
 Run test. More...
 
void setCreateAndAddElementShouldFail (bool shouldFail)
 Set calling createAndAddElement() on element stub should fail by throwing an exception. More...
 
void setPreloadShouldFail (bool shouldFail)
 Set preloading on element class should fail. More...
 
- Public Member Functions inherited from Dragengine.TestSystem.TestCase
void assertColor (Color found, Color expected, float range)
 Fail test if colors are not equal within range. More...
 
void assertDiffers (Object found, Object shouldNot)
 Fail test if found equals expected. More...
 
void assertDVector (DVector found, DVector expected)
 Fail test if vectors are not equal within range of 1mm. More...
 
void assertDVector (DVector found, DVector expected, float range)
 Fail test if vectors are not equal within range. More...
 
void assertEquals (Object found, Object expected)
 Fail test if found does not equal expected. More...
 
void assertFalse (bool found)
 Fail test if found is not false. More...
 
void assertNotNull (Object found)
 Fail test if found is not null. More...
 
void assertNull (Object found)
 Fail test if found is not null. More...
 
void assertQuaternion (Quaternion found, Quaternion expected)
 Fail test if quaternions are not equal within range of 1mm. More...
 
void assertQuaternion (Quaternion found, Quaternion expected, float range)
 Fail test if quaternions are not equal within range. More...
 
void assertThrows (Block ablock)
 Fail test if ablock does not throw an exception. More...
 
void assertTrue (bool found)
 Fail test if found is not true. More...
 
void assertVector (DVector found, DVector expected, float range)
 Fail test if vectors are not equal within range. More...
 
void assertVector (Vector found, Vector expected)
 Fail test if vectors are not equal within range of 1mm. More...
 
bool getEnabled ()
 Test case is enabled. More...
 
Exception getException ()
 Exception if test case failed. More...
 
String getID ()
 Identifier. More...
 
UnicodeString getName ()
 Display name. More...
 
State getState ()
 Test state. More...
 
TestSuite getTestSuite ()
 Test suite. More...
 
void setEnabled (bool enabled)
 Set if test case is enabled. More...
 
void setException (Exception exception)
 Set exception if test case failed. More...
 
void setState (State state)
 Set test state. More...
 
void setTestSuite (TestSuite testSuite)
 Set test suite. More...
 

Protected Member Functions

void addBehaviors ()
 Add behaviors to element class. More...
 
void assertEnumProperty (ECPEnumeration property, Enumeration value, Set enumerationValues)
 Assert element class enumeration property. More...
 
void assertFloatProperty (ECPFloat property, float value)
 Assert element class float property. More...
 
void assertFloatProperty (ECPFloat property, float value, float limitLower)
 Assert element class float property. More...
 
void assertFloatProperty (ECPFloat property, float value, float limitLower, float limitUpper)
 Assert element class float property. More...
 
void assertIntegerProperty (ECPInteger property, int value)
 Assert element class integer property. More...
 
void assertIntegerProperty (ECPInteger property, int value, int limitLower)
 Assert element class integer property. More...
 
void assertIntegerProperty (ECPInteger property, int value, int limitLower, int limitUpper)
 Assert element class integer property. More...
 
void elementCreated ()
 Element created. More...
 
BehaviorElement getElement ()
 Element to use for testing. More...
 
BehaviorElementClass getElementClass ()
 Element class to use for testing. More...
 
GameWorld getGameWorld ()
 Game world to use for testing. More...
 
PreloadCounter getPreloadCounter ()
 Preload counter used to preload element class resources. More...
 
StubElement getStubElement ()
 Stub element to use for testing. More...
 
bool testBehaviors (TestSuite testSuite)
 Test behaviors. More...
 

Additional Inherited Members

- Public Attributes inherited from Dragengine.TestSystem.TestCase
bool pEnabled
 Test case is enabled. More...
 
Exception pException
 Exception if test case failed. More...
 
String pID
 Test identifier. More...
 
UnicodeString pName
 Test name. More...
 
State pState
 Test state. More...
 
WeakReference pTestSuite
 Test suite. More...
 

Detailed Description

Base class for testing BehaviorElementClass behaviors.

Version
1.5

This class helps to test ECBehavior subclasses by providing the boiler plate code required to set up such tests. In particular this base class does the following:

  • Create a GameWorld instance
  • Create a BehaviorElementClass instance
  • Wait for preloading resources to finish
  • Create a StubElement instance
  • Create BehaviorElement instance
  • Safely tear down all created resources

This class calls hook methods at specific points during the test to allow the subclass to set up the behaviors in the required layout as well as running the tests. The following example implementation shows how a subclass can be written.

class MyTestCase extends TestCaseECBehavior
public func new()
end
protected var ECBehaviorComponent behavior
// Overwrite method to add behaviors to element class. Created behaviors
// have to be store aside if required during tests later on. Overwriting
// this method is mandatory
protected func void addBehaviors()
behavior = ECBehaviorComponent.new(getElementClass(), null)
end
// Overwrite method to set element stub properties. This simulates mapper setting
// object properties in the world editor. Overwriting this method is optional.
protected func void setStubProperties()
getStubElement().setPropertyValueFor("component.model", "/content/models/test.demodel")
end
// Overwrite method to set up element after it has been created. Overwriting
// this method is optional
protected func void elementCreated()
getElement().setPosition(DVector.new(2, 1, 3))
end
// Overwrite to run your tests on the behavior. Overwriting this method is mandatory
protected func bool testBehaviors(TestSuite testSuite)
var ECBehaviorComponent.Instance component = behavior.instance(getElement())
assertNotNull(component.getComponent())
// Return true to continue testing during the next frame update or false
// if the test finished successfully.
return false
end
end
TestCaseECBehavior new(String id, UnicodeString name)
Create test.
bool testBehaviors(TestSuite testSuite)
Test behaviors.
void addBehaviors()
Add behaviors to element class.
void elementCreated()
Element created.
StubElement getStubElement()
Stub element to use for testing.
BehaviorElement getElement()
Element to use for testing.
void assertNotNull(Object found)
Fail test if found is not null.

Member Function Documentation

◆ addBehaviors()

void Dragengine.TestSystem.TestCaseECBehavior.addBehaviors ( )
protected

Add behaviors to element class.

Reimplemented in Dragengine.TestSystem.TestCaseECBehaviorPersistency.

◆ assertEnumProperty()

void Dragengine.TestSystem.TestCaseECBehavior.assertEnumProperty ( ECPEnumeration  property,
Enumeration  value,
Set  enumerationValues 
)
protected

Assert element class enumeration property.

Version
1.12

◆ assertFloatProperty() [1/3]

void Dragengine.TestSystem.TestCaseECBehavior.assertFloatProperty ( ECPFloat  property,
float  value 
)
protected

Assert element class float property.

Version
1.12

◆ assertFloatProperty() [2/3]

void Dragengine.TestSystem.TestCaseECBehavior.assertFloatProperty ( ECPFloat  property,
float  value,
float  limitLower 
)
protected

Assert element class float property.

Version
1.12

◆ assertFloatProperty() [3/3]

void Dragengine.TestSystem.TestCaseECBehavior.assertFloatProperty ( ECPFloat  property,
float  value,
float  limitLower,
float  limitUpper 
)
protected

Assert element class float property.

Version
1.12

◆ assertIntegerProperty() [1/3]

void Dragengine.TestSystem.TestCaseECBehavior.assertIntegerProperty ( ECPInteger  property,
int  value 
)
protected

Assert element class integer property.

Version
1.12

◆ assertIntegerProperty() [2/3]

void Dragengine.TestSystem.TestCaseECBehavior.assertIntegerProperty ( ECPInteger  property,
int  value,
int  limitLower 
)
protected

Assert element class integer property.

Version
1.12

◆ assertIntegerProperty() [3/3]

void Dragengine.TestSystem.TestCaseECBehavior.assertIntegerProperty ( ECPInteger  property,
int  value,
int  limitLower,
int  limitUpper 
)
protected

Assert element class integer property.

Version
1.12

◆ elementCreated()

void Dragengine.TestSystem.TestCaseECBehavior.elementCreated ( )
protected

Element created.

Reimplemented in Dragengine.TestSystem.TestCaseECBehaviorPersistency.

◆ getCreateAndAddElementShouldFail()

bool Dragengine.TestSystem.TestCaseECBehavior.getCreateAndAddElementShouldFail ( )

Calling createAndAddElement() on element stub should fail by throwing an exception.

Version
1.12

◆ getElement()

BehaviorElement Dragengine.TestSystem.TestCaseECBehavior.getElement ( )
protected

Element to use for testing.

Reimplemented in Dragengine.TestSystem.TestCaseECBehaviorPersistency.

◆ getElementClass()

BehaviorElementClass Dragengine.TestSystem.TestCaseECBehavior.getElementClass ( )
protected

Element class to use for testing.

Reimplemented in Dragengine.TestSystem.TestCaseECBehaviorPersistency.

◆ getGameWorld()

GameWorld Dragengine.TestSystem.TestCaseECBehavior.getGameWorld ( )
protected

Game world to use for testing.

Reimplemented in Dragengine.TestSystem.TestCaseECBehaviorPersistency.

◆ getPreloadCounter()

PreloadCounter Dragengine.TestSystem.TestCaseECBehavior.getPreloadCounter ( )
protected

Preload counter used to preload element class resources.

Reimplemented in Dragengine.TestSystem.TestCaseECBehaviorPersistency.

◆ getPreloadShouldFail()

bool Dragengine.TestSystem.TestCaseECBehavior.getPreloadShouldFail ( )

Preloading on element class should fail.

Version
1.12

◆ getStubElement()

StubElement Dragengine.TestSystem.TestCaseECBehavior.getStubElement ( )
protected

Stub element to use for testing.

Reimplemented in Dragengine.TestSystem.TestCaseECBehaviorPersistency.

◆ init()

void Dragengine.TestSystem.TestCaseECBehavior.init ( )

Initialize test.

Reimplemented from Dragengine.TestSystem.TestCase.

Reimplemented in Dragengine.TestSystem.TestCaseECBehaviorPersistency.

◆ new()

TestCaseECBehavior Dragengine.TestSystem.TestCaseECBehavior.new ( String  id,
UnicodeString  name 
)

Create test.

Reimplemented from Dragengine.TestSystem.TestCase.

Reimplemented in Dragengine.TestSystem.TestCaseECBehaviorPersistency.

◆ run()

bool Dragengine.TestSystem.TestCaseECBehavior.run ( TestSuite  testSuite)

◆ setCreateAndAddElementShouldFail()

void Dragengine.TestSystem.TestCaseECBehavior.setCreateAndAddElementShouldFail ( bool  shouldFail)

Set calling createAndAddElement() on element stub should fail by throwing an exception.

Version
1.12

◆ setPreloadShouldFail()

void Dragengine.TestSystem.TestCaseECBehavior.setPreloadShouldFail ( bool  shouldFail)

Set preloading on element class should fail.

Version
1.12

◆ testBehaviors()

bool Dragengine.TestSystem.TestCaseECBehavior.testBehaviors ( TestSuite  testSuite)
protected

Test behaviors.

Reimplemented in Dragengine.TestSystem.TestCaseECBehaviorPersistency.


The documentation for this class was generated from the following file: