Using unit tests to simulate battles
So far, we have used the UTF to validate our existing ScriptableObjects containing the configuration for the units, enemies, and enemy groups. Now, we are going to add new tests using the flexibility provided by the ValueSource
attribute to dynamically create tests for different battle configurations. For this test script, which we will reference as a single battle simulation, we will create a list of combat scenarios with one unit against one enemy, the level of the unit, and whether we expect the unit to win the battle.
Before we start creating the test script, we are going to introduce a new calculation for the attack and defense attributes of the units, which will consider the level of the unit and which will increase in strength as they level up. The unit level-up feature will be developed later in Chapter 14, Crafting Buildings and Defense Towers, but we need to add the logic now to be able to test it properly. The enemies do not have the...