public void GivenCachedEntity_WhenGettingManyLocalComponents_ThenAllOfThemReturned() { // Arrange var colliders = Enumerable.Range(0, 5) .Select(i => CachedEntity.GameObject.AddComponent <BoxCollider>()) .ToArray(); // Act var returnedColliders = CachedEntity.GetMany <BoxCollider>(); // Assert Assert.That(returnedColliders, Is.EquivalentTo(colliders)); }
public void GivenInactiveSearchDisabled_WhenGettingManyInactiveLocalAndNonLocalComponents_ThenReturnNone() { // Arrange CachedEntity.SearchInInactiveChildren = false; var child = new GameObject(); child.transform.parent = CachedEntity.transform; Enumerable.Range(0, 5) .Select(i => child.AddComponent <BoxCollider>()) .ToArray(); child.SetActive(false); // Act var returnedColliders = CachedEntity.GetMany <BoxCollider>(); // Assert Assert.That(returnedColliders, Is.Empty); }
public void GivenCachedEntity_WhenGettingManyLocalAndNonLocalComponents_ThenAllOfThemReturned() { // Arrange var colliders1 = Enumerable.Range(0, 5) .Select(i => CachedEntity.GameObject.AddComponent <BoxCollider>()); var child = new GameObject(); child.transform.parent = CachedEntity.transform; var colliders2 = Enumerable.Range(0, 5) .Select(i => child.AddComponent <BoxCollider>()); var allColliders = colliders1.Concat(colliders2).ToArray(); // Act var returnedColliders = CachedEntity.GetMany <BoxCollider>(); // Assert Assert.That(returnedColliders, Is.EquivalentTo(allColliders)); }
GivenDestroyedComponentsRemoval_WhenDestroyingOneComponentAndGettingAll_ThenAllExceptTheDeletedAreReturned() { // Arrange CachedEntity.RemoveDestroyedComponents = true; var colliders = Enumerable.Range(0, 5) .Select(i => CachedEntity.GameObject.AddComponent <BoxCollider>()) .ToArray(); CachedEntity.GetMany <BoxCollider>(); // Act Object.Destroy(colliders[0]); yield return(null); var returnedColliders = CachedEntity.GetMany <BoxCollider>(); // Assert Assert.That(returnedColliders, Is.EquivalentTo(colliders.Skip(1))); }
GivenDestroyedComponentsRemovalDisabled_WhenDestroyingOneComponentAndGettingAll_ThenAllIncludingTheDeletedAreReturned() { // Arrange CachedEntity.RemoveDestroyedComponents = false; var colliders = Enumerable.Range(0, 5) .Select(i => CachedEntity.GameObject.AddComponent <BoxCollider>()) .ToArray(); CachedEntity.GetMany <BoxCollider>(); // Act Object.Destroy(colliders[1]); yield return(null); var returnedColliders = CachedEntity.GetMany <BoxCollider>(); // Assert Assert.That(returnedColliders, Is.EqualTo(colliders)); }