WIP Turret tests
This commit is contained in:
parent
0969be4955
commit
93f83c121c
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 35a6473e8e64e19c69b5a2aa7cf193d3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "Turret",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"UnityEngine.TestRunner",
|
||||
"UnityEditor.TestRunner",
|
||||
"Entities"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": true,
|
||||
"precompiledReferences": [
|
||||
"nunit.framework.dll"
|
||||
],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": [
|
||||
"UNITY_INCLUDE_TESTS"
|
||||
],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3ab67724d349675b1a6a9081eb70e62a
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f6189f795d25322fa93a6fcde3bd4b2a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,70 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AsteroidGame.Entities;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.TestTools;
|
||||
using Assert = UnityEngine.Assertions.Assert;
|
||||
|
||||
public class TurretTestScript : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private List<Turret> _turrets;
|
||||
[SerializeField] private EnemyBase _enemy;
|
||||
|
||||
[UnitySetUp]
|
||||
public IEnumerator LoadScene()
|
||||
{
|
||||
// Load the scene asynchronously and wait until it's fully loaded
|
||||
var asyncLoad = SceneManager.LoadSceneAsync("TurretTestScene");
|
||||
while (!asyncLoad.isDone)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
_turrets = new();
|
||||
_turrets = FindObjectsOfType<Turret>().ToList();
|
||||
|
||||
_enemy = new();
|
||||
_enemy = FindObjectOfType<EnemyBase>();
|
||||
}
|
||||
|
||||
// // A Test behaves as an ordinary method
|
||||
// [Test]
|
||||
// public void NewTestScriptSimplePasses()
|
||||
// {
|
||||
// // Use the Assert class to test conditions
|
||||
// }
|
||||
//
|
||||
// // A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use
|
||||
// // `yield return null;` to skip a frame.
|
||||
// [UnityTest]
|
||||
// public IEnumerator NewTestScriptWithEnumeratorPasses()
|
||||
// {
|
||||
// // Use the Assert class to test conditions.
|
||||
// // Use yield to skip a frame.
|
||||
// yield return null;
|
||||
// }
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator OnlyOneTurretGetsTheKill()
|
||||
{
|
||||
var totalKillCount = 0;
|
||||
if (_enemy != null)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var turret in _turrets)
|
||||
{
|
||||
totalKillCount += turret.Kills;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.IsTrue(totalKillCount == 1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 565b0512bfe5540aebdda54c45668c3c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue