Added basic edit mode test
This commit is contained in:
parent
3abe9a46dd
commit
60b2e598c8
@ -1,6 +1,5 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Rendering;
|
using UnityEngine.Rendering;
|
||||||
|
|
||||||
|
|||||||
20
Assets/Scripts/Ludum50.asmdef
Normal file
20
Assets/Scripts/Ludum50.asmdef
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "Ludum50",
|
||||||
|
"rootNamespace": "",
|
||||||
|
"references": [
|
||||||
|
"GUID:776d03a35f1b52c4a9aed9f56d7b4229",
|
||||||
|
"GUID:75469ad4d38634e559750d17036d5f7c",
|
||||||
|
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||||
|
"GUID:4307f53044263cf4b835bd812fc161a4",
|
||||||
|
"GUID:df380645f10b7bc4b97d4f5eb6303d95"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
||||||
7
Assets/Scripts/Ludum50.asmdef.meta
Normal file
7
Assets/Scripts/Ludum50.asmdef.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ff1917848eda86b469287c353bf3cba7
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -161,8 +161,8 @@ public class PlayerMovement : MonoBehaviour {
|
|||||||
|
|
||||||
#region States
|
#region States
|
||||||
|
|
||||||
void SwitchState(BaseState newState) {
|
public void SwitchState(BaseState newState) {
|
||||||
currentState.LeaveState();
|
currentState?.LeaveState();
|
||||||
currentState = newState;
|
currentState = newState;
|
||||||
newState.EnterState();
|
newState.EnterState();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "EditMode",
|
"name": "EditMode",
|
||||||
"optionalUnityReferences": [
|
"rootNamespace": "",
|
||||||
"TestAssemblies"
|
"references": [
|
||||||
|
"UnityEngine.TestRunner",
|
||||||
|
"UnityEditor.TestRunner",
|
||||||
|
"Ludum50"
|
||||||
],
|
],
|
||||||
"includePlatforms": [
|
"includePlatforms": [
|
||||||
"Editor"
|
"Editor"
|
||||||
]
|
],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": true,
|
||||||
|
"precompiledReferences": [
|
||||||
|
"nunit.framework.dll"
|
||||||
|
],
|
||||||
|
"autoReferenced": false,
|
||||||
|
"defineConstraints": [
|
||||||
|
"UNITY_INCLUDE_TESTS"
|
||||||
|
],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
}
|
}
|
||||||
@ -1,25 +1,15 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.TestTools;
|
|
||||||
|
|
||||||
public class EditMode
|
public class EditMode {
|
||||||
{
|
[Test]
|
||||||
// A Test behaves as an ordinary method
|
public void SwitchStateTest() {
|
||||||
[Test]
|
var gameObject = new GameObject();
|
||||||
public void EditModeSimplePasses()
|
var playerMovement = gameObject.AddComponent<PlayerMovement>();
|
||||||
{
|
|
||||||
// Use the Assert class to test conditions
|
|
||||||
}
|
|
||||||
|
|
||||||
// A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use
|
playerMovement.SwitchState(new TestState());
|
||||||
// `yield return null;` to skip a frame.
|
Assert.True(playerMovement.currentState is TestState);
|
||||||
[UnityTest]
|
}
|
||||||
public IEnumerator EditModeWithEnumeratorPasses()
|
|
||||||
{
|
class TestState : BaseState {}
|
||||||
// Use the Assert class to test conditions.
|
|
||||||
// Use yield to skip a frame.
|
|
||||||
yield return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user