public void GivenCachedEntity_WhenGettingNotExistingComponent_ThenThrowsException() { // Arrange // Act // Assert Assert.That(() => CachedEntity.Get <Rigidbody>(), Throws.Exception); }
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); }
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)); }
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)); }
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); }
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)); }
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); }