From 28f53a6f9771b95ab6f61af2bd406ea4a6a6a67f Mon Sep 17 00:00:00 2001 From: guzus Date: Tue, 17 Dec 2024 20:18:57 +0400 Subject: [PATCH 1/6] wip: door test --- Assets/02.Scripts/Tests/DoorControllerTest.cs | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Assets/02.Scripts/Tests/DoorControllerTest.cs diff --git a/Assets/02.Scripts/Tests/DoorControllerTest.cs b/Assets/02.Scripts/Tests/DoorControllerTest.cs new file mode 100644 index 00000000..27b41dd0 --- /dev/null +++ b/Assets/02.Scripts/Tests/DoorControllerTest.cs @@ -0,0 +1,73 @@ +using NUnit.Framework; +using UnityEngine; +using UnityEngine.UI; + +public class DoorControllerTests +{ + private GameObject doorControllerObject; + private DoorController doorController; + + [SetUp] + public void Setup() + { + // Create a GameObject and attach the DoorController component + doorControllerObject = new GameObject(); + doorController = doorControllerObject.AddComponent(); + + // Set up the scoreUIPanel + doorController.scoreUIPanel = new GameObject(); + doorController.scoreUIPanel.AddComponent(); + doorController.scoreUIPanel.SetActive(false); + + // Initialize answerNotes + doorController.answerNotes = new int[] { 1, 2, 3 }; // Example notes + + // Set up GameManager mock + GameManagerMock im = new GameManagerMock(); + GameManager.im = im; // Assign the mock instance + } + + [Test] + public void Inspect_ActivatesScoreUIPanel_WhenAllScoresCollected() + { + // Arrange + GameManager.im.SetAllScoresCollected(true); // Simulate all scores collected + GameObject floatingText = new GameObject("FloatingText"); // Mock floating text + + // Act + doorController.Inspect(floatingText); + + // Assert + Assert.IsTrue(doorController.scoreUIPanel.activeSelf, "Score UI panel should be active when all scores are collected."); + } + + [TearDown] + public void Teardown() + { + // Clean up + Object.DestroyImmediate(doorControllerObject); + } +} + +// Mock GameManager for testing +public class GameManagerMock +{ + public static GameManagerMock im; // Static reference for test assignment + private bool allScoresCollected; + + public void SetAllScoresCollected(bool collected) + { + allScoresCollected = collected; + } + + public bool HasAllScores() + { + return allScoresCollected; + } +} + +// GameManager (Static class for global state) +public static class GameManager +{ + public static GameManagerMock im; +} \ No newline at end of file From 5dc3880f32bd0201a895829c4e114ac1a188d8f1 Mon Sep 17 00:00:00 2001 From: guzus Date: Wed, 18 Dec 2024 14:15:08 +0900 Subject: [PATCH 2/6] feat: DoorControllerCheckNotesTest --- Assets/02.Scripts/Objects/DoorController.cs | 2 +- Assets/02.Scripts/Tests/DoorControllerTest.cs | 63 +++++++------------ .../Tests/DoorControllerTest.cs.meta | 11 ++++ 3 files changed, 34 insertions(+), 42 deletions(-) create mode 100644 Assets/02.Scripts/Tests/DoorControllerTest.cs.meta diff --git a/Assets/02.Scripts/Objects/DoorController.cs b/Assets/02.Scripts/Objects/DoorController.cs index 81c7ade8..8dd9a989 100644 --- a/Assets/02.Scripts/Objects/DoorController.cs +++ b/Assets/02.Scripts/Objects/DoorController.cs @@ -180,7 +180,7 @@ private void ResetColoredNotes() } } - private bool CheckNotes() + public bool CheckNotes() { for (int i = 0; i < playedNotes.Count; i++) { diff --git a/Assets/02.Scripts/Tests/DoorControllerTest.cs b/Assets/02.Scripts/Tests/DoorControllerTest.cs index 27b41dd0..8aba2e34 100644 --- a/Assets/02.Scripts/Tests/DoorControllerTest.cs +++ b/Assets/02.Scripts/Tests/DoorControllerTest.cs @@ -1,8 +1,7 @@ using NUnit.Framework; using UnityEngine; -using UnityEngine.UI; -public class DoorControllerTests +public class DoorControllerCheckNotesTest { private GameObject doorControllerObject; private DoorController doorController; @@ -10,64 +9,46 @@ public class DoorControllerTests [SetUp] public void Setup() { - // Create a GameObject and attach the DoorController component doorControllerObject = new GameObject(); doorController = doorControllerObject.AddComponent(); - // Set up the scoreUIPanel - doorController.scoreUIPanel = new GameObject(); - doorController.scoreUIPanel.AddComponent(); - doorController.scoreUIPanel.SetActive(false); - - // Initialize answerNotes - doorController.answerNotes = new int[] { 1, 2, 3 }; // Example notes - - // Set up GameManager mock - GameManagerMock im = new GameManagerMock(); - GameManager.im = im; // Assign the mock instance + // Initialize answerNotes for testing + doorController.answerNotes = new int[] { 1, 2, 3 }; } [Test] - public void Inspect_ActivatesScoreUIPanel_WhenAllScoresCollected() + public void CheckNotes_ReturnsTrue_WhenNotesMatch() { // Arrange - GameManager.im.SetAllScoresCollected(true); // Simulate all scores collected - GameObject floatingText = new GameObject("FloatingText"); // Mock floating text + doorController.playedNotes.Add(1); + doorController.playedNotes.Add(2); + doorController.playedNotes.Add(3); // Act - doorController.Inspect(floatingText); + bool result = doorController.CheckNotes(); // Assert - Assert.IsTrue(doorController.scoreUIPanel.activeSelf, "Score UI panel should be active when all scores are collected."); + Assert.IsTrue(result, "CheckNotes should return true when played notes match answer notes."); } - [TearDown] - public void Teardown() + [Test] + public void CheckNotes_ReturnsFalse_WhenNotesDoNotMatch() { - // Clean up - Object.DestroyImmediate(doorControllerObject); - } -} + // Arrange + doorController.playedNotes.Add(1); + doorController.playedNotes.Add(2); + doorController.playedNotes.Add(4); // Incorrect note -// Mock GameManager for testing -public class GameManagerMock -{ - public static GameManagerMock im; // Static reference for test assignment - private bool allScoresCollected; + // Act + bool result = doorController.CheckNotes(); - public void SetAllScoresCollected(bool collected) - { - allScoresCollected = collected; + // Assert + Assert.IsFalse(result, "CheckNotes should return false when played notes do not match answer notes."); } - public bool HasAllScores() + [TearDown] + public void Teardown() { - return allScoresCollected; + Object.DestroyImmediate(doorControllerObject); } -} - -// GameManager (Static class for global state) -public static class GameManager -{ - public static GameManagerMock im; } \ No newline at end of file diff --git a/Assets/02.Scripts/Tests/DoorControllerTest.cs.meta b/Assets/02.Scripts/Tests/DoorControllerTest.cs.meta new file mode 100644 index 00000000..c4f31185 --- /dev/null +++ b/Assets/02.Scripts/Tests/DoorControllerTest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a01fa94c9f0fd4b97997a5e9df751aeb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From df80dce33d4224de7d93dc09a30486eff4bf7297 Mon Sep 17 00:00:00 2001 From: guzus Date: Sat, 21 Dec 2024 02:43:06 +0900 Subject: [PATCH 3/6] chore: fix test and restrcture --- Assets/02.Scripts/Folder.DotSettings.user.meta | 7 +++++++ Assets/02.Scripts/Managers/StageManager.cs | 5 +++++ Assets/02.Scripts/Tests/EditMode.meta | 8 ++++++++ .../02.Scripts/Tests/{ => EditMode}/DoorControllerTest.cs | 0 .../Tests/{ => EditMode}/DoorControllerTest.cs.meta | 0 Assets/02.Scripts/Tests/{ => EditMode}/ProgressTest.cs | 1 + .../02.Scripts/Tests/{ => EditMode}/ProgressTest.cs.meta | 0 .../02.Scripts/Tests/{ => EditMode}/TestInputHandler.cs | 0 .../Tests/{ => EditMode}/TestInputHandler.cs.meta | 0 Assets/02.Scripts/Tests/PlayMode.meta | 8 ++++++++ 10 files changed, 29 insertions(+) create mode 100644 Assets/02.Scripts/Folder.DotSettings.user.meta create mode 100644 Assets/02.Scripts/Tests/EditMode.meta rename Assets/02.Scripts/Tests/{ => EditMode}/DoorControllerTest.cs (100%) rename Assets/02.Scripts/Tests/{ => EditMode}/DoorControllerTest.cs.meta (100%) rename Assets/02.Scripts/Tests/{ => EditMode}/ProgressTest.cs (97%) rename Assets/02.Scripts/Tests/{ => EditMode}/ProgressTest.cs.meta (100%) rename Assets/02.Scripts/Tests/{ => EditMode}/TestInputHandler.cs (100%) rename Assets/02.Scripts/Tests/{ => EditMode}/TestInputHandler.cs.meta (100%) create mode 100644 Assets/02.Scripts/Tests/PlayMode.meta diff --git a/Assets/02.Scripts/Folder.DotSettings.user.meta b/Assets/02.Scripts/Folder.DotSettings.user.meta new file mode 100644 index 00000000..181ef3de --- /dev/null +++ b/Assets/02.Scripts/Folder.DotSettings.user.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c4a336a51a7e64f6dae9403bbb667560 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.Scripts/Managers/StageManager.cs b/Assets/02.Scripts/Managers/StageManager.cs index 64cf221f..cfed61f4 100644 --- a/Assets/02.Scripts/Managers/StageManager.cs +++ b/Assets/02.Scripts/Managers/StageManager.cs @@ -22,6 +22,11 @@ public void Awake() LoadStages(); } + public void TurnOffDevelopmentMode() + { + developmentMode = false; + } + private void LoadStages() { accomplishedStages = new bool[totalStages]; diff --git a/Assets/02.Scripts/Tests/EditMode.meta b/Assets/02.Scripts/Tests/EditMode.meta new file mode 100644 index 00000000..15b857e6 --- /dev/null +++ b/Assets/02.Scripts/Tests/EditMode.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bc77803831b8c4525a010380c4b46973 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.Scripts/Tests/DoorControllerTest.cs b/Assets/02.Scripts/Tests/EditMode/DoorControllerTest.cs similarity index 100% rename from Assets/02.Scripts/Tests/DoorControllerTest.cs rename to Assets/02.Scripts/Tests/EditMode/DoorControllerTest.cs diff --git a/Assets/02.Scripts/Tests/DoorControllerTest.cs.meta b/Assets/02.Scripts/Tests/EditMode/DoorControllerTest.cs.meta similarity index 100% rename from Assets/02.Scripts/Tests/DoorControllerTest.cs.meta rename to Assets/02.Scripts/Tests/EditMode/DoorControllerTest.cs.meta diff --git a/Assets/02.Scripts/Tests/ProgressTest.cs b/Assets/02.Scripts/Tests/EditMode/ProgressTest.cs similarity index 97% rename from Assets/02.Scripts/Tests/ProgressTest.cs rename to Assets/02.Scripts/Tests/EditMode/ProgressTest.cs index b55a3ec9..821f6e06 100644 --- a/Assets/02.Scripts/Tests/ProgressTest.cs +++ b/Assets/02.Scripts/Tests/EditMode/ProgressTest.cs @@ -16,6 +16,7 @@ public void SetUp() GameObject gameObject = new GameObject(); stageManager = gameObject.AddComponent(); stageManager.totalStages = 5; + stageManager.TurnOffDevelopmentMode(); testFilePath = Path.Combine(Application.persistentDataPath, "progress.txt"); if (File.Exists(testFilePath)) { diff --git a/Assets/02.Scripts/Tests/ProgressTest.cs.meta b/Assets/02.Scripts/Tests/EditMode/ProgressTest.cs.meta similarity index 100% rename from Assets/02.Scripts/Tests/ProgressTest.cs.meta rename to Assets/02.Scripts/Tests/EditMode/ProgressTest.cs.meta diff --git a/Assets/02.Scripts/Tests/TestInputHandler.cs b/Assets/02.Scripts/Tests/EditMode/TestInputHandler.cs similarity index 100% rename from Assets/02.Scripts/Tests/TestInputHandler.cs rename to Assets/02.Scripts/Tests/EditMode/TestInputHandler.cs diff --git a/Assets/02.Scripts/Tests/TestInputHandler.cs.meta b/Assets/02.Scripts/Tests/EditMode/TestInputHandler.cs.meta similarity index 100% rename from Assets/02.Scripts/Tests/TestInputHandler.cs.meta rename to Assets/02.Scripts/Tests/EditMode/TestInputHandler.cs.meta diff --git a/Assets/02.Scripts/Tests/PlayMode.meta b/Assets/02.Scripts/Tests/PlayMode.meta new file mode 100644 index 00000000..9a6d1783 --- /dev/null +++ b/Assets/02.Scripts/Tests/PlayMode.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3554589622b954d33b6a564a8df9e520 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 32dcaa562ec3da0a1a40d36be616219324c4cfef Mon Sep 17 00:00:00 2001 From: guzus Date: Sat, 21 Dec 2024 12:24:15 +0900 Subject: [PATCH 4/6] feat: stage1 test --- .../EditModeTests.asmdef} | 2 +- .../EditModeTests.asmdef.meta} | 0 .../Tests/PlayMode/PlayModeTests.asmdef | 22 +++++++++ .../Tests/PlayMode/PlayModeTests.asmdef.meta | 7 +++ .../02.Scripts/Tests/PlayMode/Stage1Test.cs | 47 +++++++++++++++++++ .../Tests/PlayMode/Stage1Test.cs.meta | 11 +++++ 6 files changed, 88 insertions(+), 1 deletion(-) rename Assets/02.Scripts/Tests/{Tests.asmdef => EditMode/EditModeTests.asmdef} (94%) rename Assets/02.Scripts/Tests/{Tests.asmdef.meta => EditMode/EditModeTests.asmdef.meta} (100%) create mode 100644 Assets/02.Scripts/Tests/PlayMode/PlayModeTests.asmdef create mode 100644 Assets/02.Scripts/Tests/PlayMode/PlayModeTests.asmdef.meta create mode 100644 Assets/02.Scripts/Tests/PlayMode/Stage1Test.cs create mode 100644 Assets/02.Scripts/Tests/PlayMode/Stage1Test.cs.meta diff --git a/Assets/02.Scripts/Tests/Tests.asmdef b/Assets/02.Scripts/Tests/EditMode/EditModeTests.asmdef similarity index 94% rename from Assets/02.Scripts/Tests/Tests.asmdef rename to Assets/02.Scripts/Tests/EditMode/EditModeTests.asmdef index 5deb259a..156ca3b0 100644 --- a/Assets/02.Scripts/Tests/Tests.asmdef +++ b/Assets/02.Scripts/Tests/EditMode/EditModeTests.asmdef @@ -1,5 +1,5 @@ { - "name": "Tests", + "name": "EditModeTests", "rootNamespace": "", "references": [ "UnityEngine.TestRunner", diff --git a/Assets/02.Scripts/Tests/Tests.asmdef.meta b/Assets/02.Scripts/Tests/EditMode/EditModeTests.asmdef.meta similarity index 100% rename from Assets/02.Scripts/Tests/Tests.asmdef.meta rename to Assets/02.Scripts/Tests/EditMode/EditModeTests.asmdef.meta diff --git a/Assets/02.Scripts/Tests/PlayMode/PlayModeTests.asmdef b/Assets/02.Scripts/Tests/PlayMode/PlayModeTests.asmdef new file mode 100644 index 00000000..9b4441a5 --- /dev/null +++ b/Assets/02.Scripts/Tests/PlayMode/PlayModeTests.asmdef @@ -0,0 +1,22 @@ +{ + "name": "PlayModeTests", + "rootNamespace": "", + "references": [ + "UnityEngine.TestRunner", + "UnityEditor.TestRunner", + "Scripts" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/02.Scripts/Tests/PlayMode/PlayModeTests.asmdef.meta b/Assets/02.Scripts/Tests/PlayMode/PlayModeTests.asmdef.meta new file mode 100644 index 00000000..bf916993 --- /dev/null +++ b/Assets/02.Scripts/Tests/PlayMode/PlayModeTests.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d764c3f2b77e246e1898cc2ae33c42fc +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.Scripts/Tests/PlayMode/Stage1Test.cs b/Assets/02.Scripts/Tests/PlayMode/Stage1Test.cs new file mode 100644 index 00000000..1bcf21a3 --- /dev/null +++ b/Assets/02.Scripts/Tests/PlayMode/Stage1Test.cs @@ -0,0 +1,47 @@ +using UnityEngine; +using UnityEngine.SceneManagement; +using UnityEngine.TestTools; +using NUnit.Framework; +using System.Collections; + +public class Stage1Test +{ + [SetUp] + public void Setup() + { + // Load the scene + string sceneName = "Stage1"; + SceneManager.LoadScene(sceneName); + } + + [TearDown] + public void Teardown() + { + + } + + [UnityTest] + public IEnumerator TestSettingsModal() + { + yield return null; + + var canvas = GameObject.Find("Canvas"); + Assert.IsNotNull(canvas, "Canvas not found in the scene."); + + var settingsModal = canvas.transform.Find("SettingsModal")?.gameObject; + Assert.IsNotNull(settingsModal, "SettingsModal not found under Canvas."); + Assert.IsFalse(settingsModal.activeSelf, "SettingsModal should start inactive."); + + // Input.GetKeyDown(KeyCode.Escape); + // yield return null; + // Assert.IsTrue(settingsModal.activeSelf, "SettingsModal should be active after ESC key is pressed."); + } + + [UnityTest] + public IEnumerator TestScoreCountInit() + { + yield return null; + + Assert.IsFalse(GameManager.im.HasAllScores(), "All scores are not collected yet!"); + } +} \ No newline at end of file diff --git a/Assets/02.Scripts/Tests/PlayMode/Stage1Test.cs.meta b/Assets/02.Scripts/Tests/PlayMode/Stage1Test.cs.meta new file mode 100644 index 00000000..1dfe2cb6 --- /dev/null +++ b/Assets/02.Scripts/Tests/PlayMode/Stage1Test.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d488e3ff9db8b498db0a47803a204c8f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 8010917400aecd0df73e704f001079cf62d5611d Mon Sep 17 00:00:00 2001 From: guzus Date: Sat, 21 Dec 2024 12:26:53 +0900 Subject: [PATCH 5/6] chore: fix func name --- Assets/02.Scripts/Tests/EditMode/DoorControllerTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/02.Scripts/Tests/EditMode/DoorControllerTest.cs b/Assets/02.Scripts/Tests/EditMode/DoorControllerTest.cs index 8aba2e34..d6c0e63a 100644 --- a/Assets/02.Scripts/Tests/EditMode/DoorControllerTest.cs +++ b/Assets/02.Scripts/Tests/EditMode/DoorControllerTest.cs @@ -17,7 +17,7 @@ public void Setup() } [Test] - public void CheckNotes_ReturnsTrue_WhenNotesMatch() + public void TestCheckNotes_ReturnsTrue_WhenNotesMatch() { // Arrange doorController.playedNotes.Add(1); @@ -32,7 +32,7 @@ public void CheckNotes_ReturnsTrue_WhenNotesMatch() } [Test] - public void CheckNotes_ReturnsFalse_WhenNotesDoNotMatch() + public void TestCheckNotes_ReturnsFalse_WhenNotesDoNotMatch() { // Arrange doorController.playedNotes.Add(1); From adefdefec1a08d51ff86be886d8a2d80b322cf96 Mon Sep 17 00:00:00 2001 From: guzus Date: Sat, 21 Dec 2024 16:11:08 +0900 Subject: [PATCH 6/6] feat: tests for water and tree --- Assets/02.Scripts/Objects/TreeController.cs | 2 +- .../02.Scripts/Tests/PlayMode/Stage4Test.cs | 39 +++++++++++ .../Tests/PlayMode/Stage4Test.cs.meta | 11 +++ .../Tests/PlayMode/StageTutorialPlate.cs | 69 +++++++++++++++++++ .../Tests/PlayMode/StageTutorialPlate.cs.meta | 11 +++ ProjectSettings/EditorBuildSettings.asset | 3 + 6 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 Assets/02.Scripts/Tests/PlayMode/Stage4Test.cs create mode 100644 Assets/02.Scripts/Tests/PlayMode/Stage4Test.cs.meta create mode 100644 Assets/02.Scripts/Tests/PlayMode/StageTutorialPlate.cs create mode 100644 Assets/02.Scripts/Tests/PlayMode/StageTutorialPlate.cs.meta diff --git a/Assets/02.Scripts/Objects/TreeController.cs b/Assets/02.Scripts/Objects/TreeController.cs index 0b1d26d5..dce72a38 100644 --- a/Assets/02.Scripts/Objects/TreeController.cs +++ b/Assets/02.Scripts/Objects/TreeController.cs @@ -14,7 +14,7 @@ public class TreeController : Interactable [SerializeField, Range(3f, 15f)] private float prefabHeight = 13.5f; [SerializeField, Range(3f, 15f)] private float minHeight = 3f; [SerializeField, Range(3f, 15f)] private float maxHeight = 13f; - [SerializeField, Range(3f, 15f)] private float currentHeight = 8f; + [SerializeField, Range(3f, 15f)] public float currentHeight = 8f; [SerializeField, Range(0f, 1f)] private float radius = 0.7f; private readonly float heightChangeSmoothTime = 0.6f; diff --git a/Assets/02.Scripts/Tests/PlayMode/Stage4Test.cs b/Assets/02.Scripts/Tests/PlayMode/Stage4Test.cs new file mode 100644 index 00000000..8bc67108 --- /dev/null +++ b/Assets/02.Scripts/Tests/PlayMode/Stage4Test.cs @@ -0,0 +1,39 @@ +using UnityEngine; +using UnityEngine.SceneManagement; +using UnityEngine.TestTools; +using NUnit.Framework; +using System.Collections; + +public class Stage4Test +{ + [SetUp] + public void Setup() + { + // Load the scene + string sceneName = "Stage4"; + SceneManager.LoadScene(sceneName); + } + + [TearDown] + public void Teardown() + { + + } + + [UnityTest] + public IEnumerator TestWater_PlayerDiesAndRespawn() + { + yield return null; + + GameObject player = GameObject.Find("Player"); + Vector3 waterPosition = new Vector3(0, 0.5f, 0); + + // player falls into water + player.transform.position = waterPosition; + + yield return new WaitForSeconds(1); + + // player transform should be respawned + Assert.AreNotEqual(waterPosition, player.transform.position); + } +} \ No newline at end of file diff --git a/Assets/02.Scripts/Tests/PlayMode/Stage4Test.cs.meta b/Assets/02.Scripts/Tests/PlayMode/Stage4Test.cs.meta new file mode 100644 index 00000000..91a470d8 --- /dev/null +++ b/Assets/02.Scripts/Tests/PlayMode/Stage4Test.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6320fc66b02df43b3aecd6c662cc76b8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/02.Scripts/Tests/PlayMode/StageTutorialPlate.cs b/Assets/02.Scripts/Tests/PlayMode/StageTutorialPlate.cs new file mode 100644 index 00000000..62a8ceba --- /dev/null +++ b/Assets/02.Scripts/Tests/PlayMode/StageTutorialPlate.cs @@ -0,0 +1,69 @@ +using UnityEngine; +using UnityEngine.SceneManagement; +using UnityEngine.TestTools; +using NUnit.Framework; +using System.Collections; + +public class StageTutorialPlateTest +{ + [SetUp] + public void Setup() + { + // Load the scene + string sceneName = "Tutorial Plate"; + SceneManager.LoadScene(sceneName); + } + + [TearDown] + public void Teardown() + { + + } + + [UnityTest] + public IEnumerator TestTree_GrowWhenResonate() + { + yield return null; + + GameObject tree = GameObject.Find("Tree"); + Assert.IsNotNull(tree, "Tree not found in the scene."); + + Debug.Log("tree: " + tree); + + TreeController treeController = tree.GetComponent(); + float y1 = treeController.currentHeight; + + Debug.Log("y1: " + y1); + + float interval = 0.2f; // Set the interval for triggering resonance + float duration = 1f; // Total duration for triggering resonance + + float elapsedTime = 0f; + while (elapsedTime < duration) + { + tree.GetComponent().resonate(PitchType.So); + elapsedTime += interval; + yield return new WaitForSeconds(interval); + } + + float y2 = treeController.currentHeight; + + Debug.Log("y2: " + y2); + + Assert.IsTrue(y2 > y1); + + elapsedTime = 0f; + while (elapsedTime < duration) + { + tree.GetComponent().resonate(PitchType.La); + elapsedTime += interval; + yield return new WaitForSeconds(interval); + } + + float y3 = treeController.currentHeight; + + Debug.Log("y3: " + y3); + + Assert.IsTrue(y3 < y2); + } +} \ No newline at end of file diff --git a/Assets/02.Scripts/Tests/PlayMode/StageTutorialPlate.cs.meta b/Assets/02.Scripts/Tests/PlayMode/StageTutorialPlate.cs.meta new file mode 100644 index 00000000..ce230b93 --- /dev/null +++ b/Assets/02.Scripts/Tests/PlayMode/StageTutorialPlate.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: acf2dc436f07640c597f1b420486eb7f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 980f7351..defce634 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -29,4 +29,7 @@ EditorBuildSettings: - enabled: 1 path: Assets/01.Scenes/Stages/Tutorial/Stage6.unity guid: 278c9aa1ca7861a41ae82bc9bb7100db + - enabled: 1 + path: Assets/01.Scenes/Stages/Tutorial Plate.unity + guid: 7b6a2b9ea4c971b4a810622b42cbfff5 m_configObjects: {}