Пример #1
0
        public void GivenCachedEntity_WhenGettingNotExistingComponent_ThenThrowsException()
        {
            // Arrange

            // Act

            // Assert
            Assert.That(() => CachedEntity.Get <Rigidbody>(), Throws.Exception);
        }
Пример #2
0
        public void CachedEntityWithInactiveSearchDisabled_GetInactiveChildComponent_ThrowsException()
        {
            var child = new GameObject();

            child.transform.parent = CachedEntity.GameObject.transform;
            child.AddComponent <Rigidbody>();
            child.SetActive(false);
            CachedEntity.SearchInInactiveChildren = false;

            Assert.That(() => CachedEntity.Get <Rigidbody>(), Throws.Exception);
        }
Пример #3
0
        public void GivenCachedEntity_WhenGettingLocalComponent_ThenTheComponentIsReturned()
        {
            // Arrange
            var rigidbody = CachedEntity.GameObject.AddComponent <Rigidbody>();

            // Act
            var returnedRigidbody = CachedEntity.Get <Rigidbody>();

            // Assert
            Assert.That(returnedRigidbody, Is.EqualTo(rigidbody));
        }
Пример #4
0
        public void GivenCachedEntity_WhenGettingChildComponent_ThenTheComponentIsReturned()
        {
            // Arrange
            var child = new GameObject();

            child.transform.parent = CachedEntity.GameObject.transform;
            var rigidbody = child.AddComponent <Rigidbody>();

            // Act
            var returnedRigidbody = CachedEntity.Get <Rigidbody>();

            // Assert
            Assert.That(returnedRigidbody, Is.EqualTo(rigidbody));
        }
Пример #5
0
        public IEnumerator GivenDestroyedComponentsRemovalEnabled_WhenGettingDestroyedComponent_ThenThrowsException()
        {
            // Arrange
            CachedEntity.RemoveDestroyedComponents = true;
            var rigidbody = CachedEntity.GameObject.AddComponent <Rigidbody>();

            CachedEntity.Get <Rigidbody>();

            // Act
            Object.Destroy(rigidbody);
            yield return(null);

            // Assert
            Assert.That(() => CachedEntity.Get <Rigidbody>(), Throws.Exception);
        }
Пример #6
0
        public void GivenInactiveSearchEnabled_WhenInactiveChildComponent_ThenTheComponentIsReturned()
        {
            // Arrange
            var child = new GameObject();

            child.transform.parent = CachedEntity.GameObject.transform;
            var rigidbody = child.AddComponent <Rigidbody>();

            child.SetActive(false);
            CachedEntity.SearchInInactiveChildren = true;

            // Act
            var returnedRigidbody = CachedEntity.Get <Rigidbody>();

            // Assert
            Assert.That(returnedRigidbody, Is.EqualTo(rigidbody));
        }
Пример #7
0
        public IEnumerator GivenDestroyedComponentsRemovalDisabled_WhenGettingDestroyedComponent_ThenNullIsReturned()
        {
            // Arrange
            CachedEntity.RemoveDestroyedComponents = false;
            var rigidbody = CachedEntity.GameObject.AddComponent <Rigidbody>();

            CachedEntity.Get <Rigidbody>();

            // Act
            Object.Destroy(rigidbody);
            yield return(null);

            var returnedRigidbody = CachedEntity.Get <Rigidbody>();

            // Assert
            Assert.That(returnedRigidbody == null);
        }