Skip to Main Content
Table of Contents

BTD_Mod_Helper​.Api​.Testing​.ModTest


BloonsTD6 Mod Helper

BTD_Mod_Helper.Api.Testing

ModTest Class

Defines a test task for a mod

public abstract class ModTest : BTD_Mod_Helper.Api.ModContent

Inheritance System.ObjectModContent  ModTest

Derived
ModContentDefaultTest<T>

Fields

ModTest.DefaultDifficulty Field

Default difficulty to use

public static readonly string DefaultDifficulty;

Field Value

System.String

ModTest.DefaultMap Field

Default map to use

public static readonly string DefaultMap;

Field Value

System.String

ModTest.DefaultMode Field

Default mode to use

public static readonly string DefaultMode;

Field Value

System.String

Properties

ModTest.Bridge Property

The current UnityToSimulation, either from the Simulation Test Environment or the current game

public UnityToSimulation Bridge { get; }

Property Value

Il2CppAssets.Scripts.Unity.Bridge.UnityToSimulation

ModTest.Completed Property

Whether the current run of this test has completed

public bool Completed { get; set; }

Property Value

System.Boolean

ModTest.Environment Property

Current SimulationTestEnvironment. Use SetupSimEnvironment(Action<SimulationTest>) to set it up, and DisposeSimEnvironment() to dispose

public SimulationTestEnvironment Environment { get; set; }

Property Value

Il2CppAssets.Scripts.SimulationTests.SimulationTestEnvironment

ModTest.Exception Property

Exception that happened in the most recent run of this test, if any

public System.Exception Exception { get; set; }

Property Value

System.Exception

ModTest.Failed Property

Whether the most recent run of this test failed to complete successfully

public bool Failed { get; }

Property Value

System.Boolean

ModTest.IsAvailable Property

Whether this test is available for purposes like running every test added by a mod

public virtual bool IsAvailable { get; }

Property Value

System.Boolean

ModTest.Suceeded Property

Whether the most recent run of this test completed successfully

public bool Suceeded { get; }

Property Value

System.Boolean

Methods

ModTest.Assert(bool, string) Method

Throws an BTD_Mod_Helper.Api.Testing.ModTest.AssertException if the given condition is not true

public void Assert(bool condition, string message="");

Parameters

condition System.Boolean

Condition that must be true for the test to continue

message System.String

Optional message describing the failure

ModTest.AssertComponentExists(string, string) Method

Throws an BTD_Mod_Helper.Api.Testing.ModTest.AssertException if no UnityEngine.Component of type T
with the given name can be found within any currently loaded scene

public T AssertComponentExists<T>(string name, string message="")
    where T : Component;

Type parameters

T

Component type to search for

Parameters

name System.String

Name of the GameObject the component should be attached to

message System.String

Optional message describing the failure

Returns

T

ModTest.AssertEquals(object, object, string) Method

Throws an BTD_Mod_Helper.Api.Testing.ModTest.AssertException if the two given objects are not equal

public void AssertEquals(object o1, object o2, string message="");

Parameters

o1 System.Object

First object to compare

o2 System.Object

Second object to compare

message System.String

Optional message describing the failure

ModTest.AssertNotNull(T, string) Method

Throws an BTD_Mod_Helper.Api.Testing.ModTest.AssertException if the given object is null

public T AssertNotNull<T>(T obj, string message="");

Type parameters

T

Parameters

obj T

message System.String

Optional message describing the failure

Returns

T

ModTest.AssertThrows(Action, string) Method

Throws an BTD_Mod_Helper.Api.Testing.ModTest.AssertException if the given action does not throw an exception

public void AssertThrows(System.Action action, string message="");

Parameters

action System.Action

Action that is expected to throw

message System.String

Optional message describing the failure

ModTest.AssertThrows(Action, string) Method

Throws an BTD_Mod_Helper.Api.Testing.ModTest.AssertException if the given action does not throw an exception of type T

public void AssertThrows<T>(System.Action action, string message="");

Type parameters

T

Type of exception that the action is expected to throw

Parameters

action System.Action

Action that is expected to throw

message System.String

Optional message describing the failure

ModTest.CreateTowerAt(UnityToSimulation, Vector2, TowerModel, bool, bool, int) Method

Helper to create a tower model at a specific location. Ignores placement/inventory checks and cost

public static TowerToSimulation CreateTowerAt(UnityToSimulation bridge, Vector2 at, TowerModel towerModel, bool ignoreInventoryChecks=true, bool ignorePlacementChecks=true, int costOverride=-1);

Parameters

bridge Il2CppAssets.Scripts.Unity.Bridge.UnityToSimulation

UnityToSimulation

at UnityEngine.Vector2

tower coordinates

towerModel Il2CppAssets.Scripts.Models.Towers.TowerModel

TowerModel to use

ignoreInventoryChecks System.Boolean

place regardless of TowerInventory restrictions

ignorePlacementChecks System.Boolean

place regardless of placement restrictions

costOverride System.Int32

override purchase cost, -1 to not override (default

Returns

Il2CppAssets.Scripts.Unity.Bridge.TowerToSimulation
Created TowerToSimulation

ModTest.DisposeSimEnvironment() Method

Tears down the current Environment

public void DisposeSimEnvironment();

ModTest.EnsureOnMainMenuWithNoPopUps() Method

Ensures that the game is on the main menu screen with no popups before continuing

public System.Collections.IEnumerator EnsureOnMainMenuWithNoPopUps();

Returns

System.Collections.IEnumerator

ModTest.Fail(string) Method

Unconditionally fails the test with the given message

public void Fail(string message="");

Parameters

message System.String

Optional message describing the failure

ModTest.LoadIntoGame(InGameData) Method

Loads the game into a real match of BTD6

public System.Collections.IEnumerator LoadIntoGame(InGameData inGameData=null);

Parameters

inGameData Il2CppAssets.Scripts.Unity.UI_New.InGame.InGameData

specifics about game type

Returns

System.Collections.IEnumerator

ModTest.RunTest() Method

Runs the test coroutine

public System.Collections.IEnumerator RunTest();

Returns

System.Collections.IEnumerator

ModTest.SetupSimEnvironment(Action) Method

Sets up a Il2CppAssets.Scripts.SimulationTests.SimulationTestEnvironment to use for test, storing it at Environment
Used for testing matches without actually starting a real game

public System.Collections.IEnumerator SetupSimEnvironment(System.Action<SimulationTest> setupTest=null);

Parameters

setupTest System.Action<Il2Cpp.SimulationTest>

Returns

System.Collections.IEnumerator

ModTest.Test() Method

Primary test coroutine

public abstract System.Collections.IEnumerator Test();

Returns

System.Collections.IEnumerator

ModTest.Throw(Exception) Method

Records and throws the given exception, causing the test to fail

public void Throw(System.Exception e);

Parameters

e System.Exception

ModTest.Timeout(object, float) Method

Wraps a coroutine so that the test will fail if it does not complete within the given time

public System.Collections.IEnumerator Timeout(object coroutine, float seconds);

Parameters

coroutine System.Object

Coroutine (managed or Il2Cpp) or yield value to run with a timeout

seconds System.Single

Maximum number of seconds the coroutine is allowed to run for

Returns

System.Collections.IEnumerator

ModTest.UpgradeTower(UnityToSimulation, ObjectId, int) Method

Upgrades a tower on a specified path

public static bool UpgradeTower(UnityToSimulation bridge, ObjectId tower, int path);

Parameters

bridge Il2CppAssets.Scripts.Unity.Bridge.UnityToSimulation

UnityToSimulation bridge

tower Il2CppAssets.Scripts.ObjectId

The tower to upgrade

path System.Int32

The upgrade path index

Returns

System.Boolean

ModTest.UpgradeTower(UnityToSimulation, Tower, int) Method

Upgrades a tower on a specified path

public static bool UpgradeTower(UnityToSimulation bridge, Tower tower, int path);

Parameters

bridge Il2CppAssets.Scripts.Unity.Bridge.UnityToSimulation

UnityToSimulation bridge

tower Il2CppAssets.Scripts.Simulation.Towers.Tower

The tower to upgrade

path System.Int32

The upgrade path index

Returns

System.Boolean

ModTest.UpgradeTower(UnityToSimulation, TowerToSimulation, int) Method

Upgrades a tower on a specified path

public static bool UpgradeTower(UnityToSimulation bridge, TowerToSimulation tower, int path);

Parameters

bridge Il2CppAssets.Scripts.Unity.Bridge.UnityToSimulation

UnityToSimulation bridge

tower Il2CppAssets.Scripts.Unity.Bridge.TowerToSimulation

The tower to upgrade

path System.Int32

The upgrade path index

Returns

System.Boolean

ModTest.UpgradeTowerParagon(UnityToSimulation, ObjectId) Method

Upgrades a tower to being a paragon

public static bool UpgradeTowerParagon(UnityToSimulation bridge, ObjectId tower);

Parameters

bridge Il2CppAssets.Scripts.Unity.Bridge.UnityToSimulation

UnityToSimulation bridge

tower Il2CppAssets.Scripts.ObjectId

The tower to upgrade

Returns

System.Boolean

ModTest.UpgradeTowerParagon(UnityToSimulation, Tower) Method

Upgrades a tower to being a paragon

public static bool UpgradeTowerParagon(UnityToSimulation bridge, Tower tower);

Parameters

bridge Il2CppAssets.Scripts.Unity.Bridge.UnityToSimulation

UnityToSimulation bridge

tower Il2CppAssets.Scripts.Simulation.Towers.Tower

The tower to upgrade

Returns

System.Boolean

ModTest.UpgradeTowerParagon(UnityToSimulation, TowerToSimulation) Method

Upgrades a tower to being a paragon

public static bool UpgradeTowerParagon(UnityToSimulation bridge, TowerToSimulation tower);

Parameters

bridge Il2CppAssets.Scripts.Unity.Bridge.UnityToSimulation

UnityToSimulation bridge

tower Il2CppAssets.Scripts.Unity.Bridge.TowerToSimulation

The tower to upgrade

Returns

System.Boolean