Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions Assets/APIExamples/Tests/Runtime/NUnit/ConstraintExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -935,15 +935,33 @@ public void XmlSerializableConstraint_XMLシリアル化が可能であること
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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void CustomConstraint_Constraintの実装だけで可能な書きかた()

[Test]
[UnityPlatform(RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor)]
// Note: プレイヤーではnull判定されるため除外
// Note: Playerでは破棄されたObjectの参照はnull判定されるため除外
public void CustomConstraint_Extensionsの実装も行なうと可能な書きかた()
{
var actual = CreateDestroyedObject();
Expand Down