-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
…for-2024-fall-swpp-team-16 into refactor/final-refactor
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using NUnit.Framework; | ||
using UnityEngine; | ||
|
||
public class DoorControllerCheckNotesTest | ||
{ | ||
private GameObject doorControllerObject; | ||
private DoorController doorController; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
doorControllerObject = new GameObject(); | ||
doorController = doorControllerObject.AddComponent<DoorController>(); | ||
|
||
// Initialize answerNotes for testing | ||
doorController.answerNotes = new int[] { 1, 2, 3 }; | ||
} | ||
|
||
[Test] | ||
public void TestCheckNotes_ReturnsTrue_WhenNotesMatch() | ||
{ | ||
// Arrange | ||
doorController.playedNotes.Add(1); | ||
doorController.playedNotes.Add(2); | ||
doorController.playedNotes.Add(3); | ||
|
||
// Act | ||
bool result = doorController.CheckNotes(); | ||
|
||
// Assert | ||
Assert.IsTrue(result, "CheckNotes should return true when played notes match answer notes."); | ||
} | ||
|
||
[Test] | ||
public void TestCheckNotes_ReturnsFalse_WhenNotesDoNotMatch() | ||
{ | ||
// Arrange | ||
doorController.playedNotes.Add(1); | ||
doorController.playedNotes.Add(2); | ||
doorController.playedNotes.Add(4); // Incorrect note | ||
|
||
// Act | ||
bool result = doorController.CheckNotes(); | ||
|
||
// Assert | ||
Assert.IsFalse(result, "CheckNotes should return false when played notes do not match answer notes."); | ||
} | ||
|
||
[TearDown] | ||
public void Teardown() | ||
{ | ||
Object.DestroyImmediate(doorControllerObject); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "Tests", | ||
"name": "EditModeTests", | ||
"rootNamespace": "", | ||
"references": [ | ||
"UnityEngine.TestRunner", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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!"); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "Stage7"; | ||
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<TreeController>(); | ||
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<ResonatableObject>().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<ResonatableObject>().resonate(PitchType.La); | ||
elapsedTime += interval; | ||
yield return new WaitForSeconds(interval); | ||
} | ||
|
||
float y3 = treeController.currentHeight; | ||
|
||
Debug.Log("y3: " + y3); | ||
|
||
Assert.IsTrue(y3 < y2); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.