1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-10 11:55:41 +00:00
X10D/X10D.Unity.Tests/Assets/Tests/ComponentTests.cs

30 lines
786 B
C#
Raw Normal View History

2022-05-08 12:09:30 +01:00
#nullable enable
using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
namespace X10D.Unity.Tests
2022-05-08 12:09:30 +01:00
{
public class ComponentTests
{
[UnityTest]
public IEnumerator GetComponentsInChildrenOnly_ShouldIgnoreParent()
{
var parent = new GameObject();
var rigidbody = parent.AddComponent<Rigidbody>();
var child = new GameObject();
child.transform.SetParent(parent.transform);
child.AddComponent<Rigidbody>();
Rigidbody[] components = rigidbody.GetComponentsInChildrenOnly<Rigidbody>();
Assert.AreEqual(1, components.Length);
Assert.AreEqual(components[0].gameObject, child);
yield break;
}
}
}