Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
GameObject.Find finds objects in inactive scenes.
  • Loading branch information
nowsprinting committed Oct 22, 2023
1 parent 472135c commit 4cbd683
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions Tests/Runtime/Attributes/CreateSceneAttributeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Collections;
using System.Threading.Tasks;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;

Expand All @@ -21,11 +20,8 @@ public void Attach_CreateNewSceneWithoutCameraAndLight()
Assert.That(scene.name, Is.EqualTo(
"Scene of TestHelper.Attributes.CreateSceneAttributeTest.Attach_CreateNewSceneWithoutCameraAndLight"));

var camera = GameObject.Find("Main Camera");
Assert.That(camera, Is.Null);

var light = GameObject.Find("Directional Light");
Assert.That(light, Is.Null);
var rootGameObjects = scene.GetRootGameObjects(); // Note: GameObject.Find finds objects in inactive scenes
Assert.That(rootGameObjects, Is.Empty);
}

[Test]
Expand All @@ -36,8 +32,9 @@ public void Attach_WithCamera_CreateNewSceneWithCamera()
Assert.That(scene.name, Is.EqualTo(
"Scene of TestHelper.Attributes.CreateSceneAttributeTest.Attach_WithCamera_CreateNewSceneWithCamera"));

var camera = GameObject.Find("Main Camera");
Assert.That(camera, Is.Not.Null);
var rootGameObjects = scene.GetRootGameObjects(); // Note: GameObject.Find finds objects in inactive scenes
Assert.That(rootGameObjects, Has.Length.EqualTo(1));
Assert.That(rootGameObjects[0].name, Is.EqualTo("Main Camera"));
}

[Test]
Expand All @@ -48,8 +45,9 @@ public void Attach_WithLight_CreateNewSceneWithLight()
Assert.That(scene.name, Is.EqualTo(
"Scene of TestHelper.Attributes.CreateSceneAttributeTest.Attach_WithLight_CreateNewSceneWithLight"));

var light = GameObject.Find("Directional Light");
Assert.That(light, Is.Not.Null);
var rootGameObjects = scene.GetRootGameObjects(); // Note: GameObject.Find finds objects in inactive scenes
Assert.That(rootGameObjects, Has.Length.EqualTo(1));
Assert.That(rootGameObjects[0].name, Is.EqualTo("Directional Light"));
}

[Test]
Expand Down

0 comments on commit 4cbd683

Please sign in to comment.