diff --git a/Assets/APIExamples/Tests/Runtime/NUnit/ConstraintExample.cs b/Assets/APIExamples/Tests/Runtime/NUnit/ConstraintExample.cs index 55a1fb0..256f63b 100644 --- a/Assets/APIExamples/Tests/Runtime/NUnit/ConstraintExample.cs +++ b/Assets/APIExamples/Tests/Runtime/NUnit/ConstraintExample.cs @@ -935,15 +935,33 @@ public class XmlSerializableSample public class 破棄されたGameObject { [Test] - [UnityPlatform(RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor)] - // Note: プレイヤーではnull判定されるため除外 public void Boolキャストオペレーターで破棄されたGameObjectを検証する例() { - var cube = new GameObject("Cube"); - GameObject.DestroyImmediate(cube); + var go = new GameObject(); + GameObject.DestroyImmediate(go); + + Assert.That((bool)go, Is.False); // Note: GameObjectが破棄されているとき、boolキャストオペレーターはfalseを返す + } + + [Test] + [UnityPlatform(RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor)] + public void IsNullで破棄されたGameObjectを検証する例_EditorではNotNull() + { + var go = new GameObject(); + GameObject.DestroyImmediate(go); + + Assume.That(go, Is.Not.Null); // Note: Editorでは破棄されていても参照はnullではない + } + + [Test] + [UnityPlatform(exclude = + new[] { RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor })] + public void IsNullで破棄されたGameObjectを検証する例_PlayerではNull() + { + var go = new GameObject(); + GameObject.DestroyImmediate(go); - Assume.That(cube, Is.Not.Null); // Note: 破棄されていても参照はnullではない - Assert.That((bool)cube, Is.False); // Note: GameObjectが破棄されているとき、boolキャストオペレーターはfalseを返す + Assume.That(go, Is.Null); // Note: Playerでは破棄されたObjectの参照はnull } } diff --git a/Assets/APIExamples/Tests/Runtime/NUnit/CustomConstraintExample.cs b/Assets/APIExamples/Tests/Runtime/NUnit/CustomConstraintExample.cs index 77e73c5..63418cb 100644 --- a/Assets/APIExamples/Tests/Runtime/NUnit/CustomConstraintExample.cs +++ b/Assets/APIExamples/Tests/Runtime/NUnit/CustomConstraintExample.cs @@ -36,7 +36,7 @@ private static GameObject CreateDestroyedObject() [Test] [UnityPlatform(RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor)] - // Note: プレイヤーではnull判定されるため除外 + // Note: Playerでは破棄されたObjectの参照はnull判定されるため除外 public void CustomConstraint_Extensionsの実装も行なうと可能な書きかた() { var actual = CreateDestroyedObject();