-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from Wizards-vs-Robots/wavemanager_test
Wavemanager test
- Loading branch information
Showing
10 changed files
with
202 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
using Robot; | ||
using UnityEditor.SceneManagement; | ||
using UnityEditor.SearchService; | ||
using UnityEngine; | ||
using UnityEngine.SceneManagement; | ||
using UnityEngine.TestTools; | ||
|
||
public class MinionConstellationTest | ||
{ | ||
[Test] | ||
public void TestMinionConstellation() | ||
{ | ||
EditorSceneManager.OpenScene("Assets/Scenes/Game.unity"); | ||
|
||
var manager = GameObject | ||
.FindGameObjectsWithTag("WaveManager")[0] | ||
.GetComponent<WaveManager>(); | ||
manager.Start(); | ||
|
||
List<Tuple<float, Attacker>> pattern = manager.GenerateSpawnPattern(); | ||
int firstRobotCount = 0; | ||
foreach (Tuple<float, Attacker> entry in pattern) { | ||
Assert.IsTrue(entry.Item2.strength == 10); | ||
firstRobotCount++; | ||
} | ||
|
||
Assert.IsTrue(firstRobotCount == 10); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Assets/Tests/Playmode/Testtest.cs.meta → .../Editmode/MinionConstellationTest.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using NUnit.Framework; | ||
using Robot; | ||
using UnityEditor.SceneManagement; | ||
using UnityEngine; | ||
using UnityEngine.TestTools; | ||
using UnityEngine.UIElements; | ||
|
||
public class ParameterGrowthTest | ||
{ | ||
[Test] | ||
public void TestParameterGrowth() | ||
{ | ||
EditorSceneManager.OpenScene("Assets/Scenes/Game.unity"); | ||
|
||
float eta = 10e-4F; | ||
float[] cooldowns = new float[3]{1F, 0.9950125F, 0.9900498F}; | ||
float[] durations = new float[3]{5F, 4.900993F, 4.803947F}; | ||
float[] strengths = new float[3]{100F, 104.0811F, 108.3287F}; | ||
var manager = GameObject | ||
.FindGameObjectsWithTag("WaveManager")[0] | ||
.GetComponent<WaveManager>(); | ||
manager.cooldown = 1F; | ||
manager.duration = 5F; | ||
manager.strength = 100F; | ||
manager.wave = 1; | ||
|
||
for (int i = 0; i < 3; i++) { | ||
Assert.IsTrue(Mathf.Abs(manager.cooldown - cooldowns[i]) < eta); | ||
Assert.IsTrue(Mathf.Abs(manager.duration - durations[i]) < eta); | ||
Assert.IsTrue(Mathf.Abs(manager.strength - strengths[i]) < eta); | ||
|
||
manager.wave += 1; | ||
manager.Strengthen(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
using Robot; | ||
using UnityEditor.SceneManagement; | ||
using UnityEngine; | ||
using UnityEngine.TestTools; | ||
|
||
public class ReportDeathTest | ||
{ | ||
[Test] | ||
public void TestDeathAlreadyReported() | ||
{ | ||
EditorSceneManager.OpenScene("Assets/Scenes/Game.unity"); | ||
|
||
Statics.Initialize(); | ||
var manager = GameObject | ||
.FindGameObjectsWithTag("WaveManager")[0] | ||
.GetComponent<WaveManager>(); | ||
manager.Start(); | ||
|
||
// Simulate spawning | ||
var spawnVector = new Vector3(0F, 0F, 0F); | ||
var firstAttacker = manager.attackers[0]; | ||
manager.Spawn(firstAttacker, spawnVector); | ||
|
||
// Take first minion | ||
var firstMinion = manager.minions[0]; | ||
var strength = (int) firstMinion.GetComponent<Attacker>().GetStrength(); | ||
|
||
// Report death first time | ||
var sizeBefore = manager.minions.Count; | ||
manager.ReportDeath(firstMinion); | ||
var currentSize = manager.minions.Count; | ||
|
||
// Assert functioning first report | ||
Assert.IsTrue(currentSize < sizeBefore); | ||
Assert.IsTrue(Statics.GetScoreModel().GetScore() == strength); | ||
|
||
// Report death as second time (should be ignored) | ||
sizeBefore = currentSize; | ||
manager.ReportDeath(firstMinion); | ||
currentSize = manager.minions.Count; | ||
|
||
// Assert ignored death report | ||
Assert.IsTrue(currentSize == sizeBefore); | ||
Assert.IsTrue(Statics.GetScoreModel().GetScore() == strength); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
using Robot; | ||
using UnityEditor.SceneManagement; | ||
using UnityEngine; | ||
using UnityEngine.TestTools; | ||
|
||
public class SpawnRobotTest | ||
{ | ||
[Test] | ||
public void TestSpawnRobot() | ||
{ | ||
EditorSceneManager.OpenScene("Assets/Scenes/Game.unity"); | ||
|
||
var manager = GameObject | ||
.FindGameObjectsWithTag("WaveManager")[0] | ||
.GetComponent<WaveManager>(); | ||
manager.Start(); | ||
|
||
// Spawn attacker | ||
var spawnVector = new Vector3(0F, 0F, 0F); | ||
var firstAttacker = manager.attackers[0]; | ||
manager.Spawn(firstAttacker, spawnVector); | ||
|
||
// Retrieve instance | ||
var attackerInstance = manager.minions[0]; | ||
var difVector = attackerInstance.transform.position - spawnVector; | ||
var distance = difVector.magnitude; | ||
|
||
// Check if in valid range | ||
Assert.IsTrue(distance >= WaveManager.MIN_SPAWN_RADIUS && | ||
distance <= WaveManager.MAX_SPAWN_RADIUS); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.