Skip to content

Commit

Permalink
🔀 Merge pull request #47 from soo-bak/46-refactor-tests-of-gameobject…
Browse files Browse the repository at this point in the history
…adapter

♻️ Refactor GameObjectAdapter PlayTest (#46)
  • Loading branch information
soo-bak committed Sep 22, 2024
2 parents 0bab9a6 + daeace3 commit e97a9b5
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions Tests/Runtime/GameObjectAdapterPlayTests.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void TestMethod(object parameter = null) {
private GameObject testGo = null;

[OneTimeSetUp]
public void OneTimeSetup() {
public void OneTimeSetup() {
EditorSettings.enterPlayModeOptionsEnabled = true;
EditorSettings.enterPlayModeOptions = EnterPlayModeOptions.DisableDomainReload;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ public IEnumerator G_GameObjectAdapter_W_InstantiateWithPositionAndParent_T_NewG
public IEnumerator G_GameObjectAdapter_W_SendMessage_T_MessageIsSent() {
// Arrange
var mockBehaviour = testGo.AddComponent<MonobehaviorSpy>();

// Act
goAdapter.SendMessage(TEST_METHOD_NAME, TEST_PARAMETER_NAME, SendMessageOptions.RequireReceiver);
yield return null; // Wait for a frame to ensure the message is processed
Expand Down Expand Up @@ -208,7 +208,7 @@ public IEnumerator G_GameObjectAdapter_W_BroadcastMessage_T_MessageIsBroadcasted
// Clean up
Object.Destroy(childObj);
}

[UnityTest]
public IEnumerator G_GameObjectAdapter_W_FindWithTag_T_ReturnsCorrectGameObjectAdapter() {
// Arrange
Expand Down Expand Up @@ -254,16 +254,14 @@ private void InitTagConfig(string tagName) {
var tagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
var targetPropName = "tags";
var tagsProp = tagManager.FindProperty(targetPropName);

bool isFound = false;
for (int i = 0; i < tagsProp.arraySize; i++) {
SerializedProperty t = tagsProp.GetArrayElementAtIndex(i);
if (t.stringValue.Equals(tagName)) {
if (t.stringValue.Equals(tagName))
isFound = true;
break ;
}
}

if (!isFound) {
tagsProp.InsertArrayElementAtIndex(0);
SerializedProperty newTag = tagsProp.GetArrayElementAtIndex(0);
Expand All @@ -273,4 +271,4 @@ private void InitTagConfig(string tagName) {
}
}

} // namespace
} // namespace

0 comments on commit e97a9b5

Please sign in to comment.