Beispiel #1
0
        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));
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        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)));
        }
Beispiel #5
0
        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));
        }