public void RequireComponent_NoAttachedComponent_Test() { GameObject objectUnderTest = new GameObject("test obj"); ExampleUnityComponent returnedComponent = objectUnderTest.transform.RequireComponent <ExampleUnityComponent>(); LogAssert.Expect(LogType.Exception, ANY_STRING); Assert.IsNull(returnedComponent); }
public void RequireComponent_AttachedComponent_Test() { GameObject objectUnderTest = new GameObject("test obj"); ExampleUnityComponent addedComponent = objectUnderTest.AddComponent <ExampleUnityComponent>(); ExampleUnityComponent returnedComponent = objectUnderTest.transform.RequireComponent <ExampleUnityComponent>(); Assert.AreSame(addedComponent, returnedComponent); }
public void FindComponentInScene_1arg_null_when_object_doesnt_exist() { GameObject objectUnderTest = new GameObject("test obj"); ExampleUnityComponent foundComponent = SceneUtils.FindComponentInScene <ExampleUnityComponent>("secondObj"); LogAssert.Expect(LogType.Exception, ANY_STRING); Assert.IsNull(foundComponent); }
public void FindComponentInScene_1arg_finds_component() { GameObject objectUnderTest = new GameObject("test obj"); ExampleUnityComponent addedComponent = objectUnderTest.AddComponent <ExampleUnityComponent>(); ExampleUnityComponent foundComponent = SceneUtils.FindComponentInScene <ExampleUnityComponent>("test obj"); Assert.AreSame(addedComponent, foundComponent); }
public void FindComponentInScene_1arg_null_when_wrong_name() { GameObject objectUnderTest = new GameObject("test obj"); GameObject secondObject = new GameObject("secondObj"); ExampleUnityComponent addedComponent = objectUnderTest.AddComponent <ExampleUnityComponent>(); ExampleUnityComponent foundComponent = SceneUtils.FindComponentInScene <ExampleUnityComponent>("secondObj"); LogAssert.Expect(LogType.Exception, ANY_STRING); Assert.IsNull(foundComponent); }
public void FindComponentInScene_no_component_exists() { GameObject objectUnderTest = new GameObject("test obj"); GameObject childobject = new GameObject("childObj"); childobject.transform.parent = objectUnderTest.transform; ExampleUnityComponent foundComponent = SceneUtils.FindComponentInScene <ExampleUnityComponent>(); LogAssert.Expect(LogType.Exception, ANY_STRING); Assert.IsNull(foundComponent); }
public void FindComponentInScene_finds_child_level_component() { GameObject objectUnderTest = new GameObject("test obj"); GameObject childobject = new GameObject("childObj"); childobject.transform.parent = objectUnderTest.transform; ExampleUnityComponent addedComponent = childobject.AddComponent <ExampleUnityComponent>(); ExampleUnityComponent foundComponent = SceneUtils.FindComponentInScene <ExampleUnityComponent>(); Assert.AreSame(addedComponent, foundComponent); }
public void RequireComponent_AttachedComponentToChild_Test() { GameObject objectUnderTest = new GameObject("test obj"); GameObject childObject = new GameObject("childobj"); ExampleUnityComponent addedComponent = childObject.AddComponent <ExampleUnityComponent>(); childObject.transform.parent = objectUnderTest.transform; ExampleUnityComponent returnedComponent = objectUnderTest.transform.RequireComponent <ExampleUnityComponent>(); LogAssert.Expect(LogType.Exception, ANY_STRING); Assert.IsNull(returnedComponent); ExampleUnityComponent childReturnedComponent = childObject.transform.RequireComponent <ExampleUnityComponent>(); Assert.AreSame(addedComponent, childReturnedComponent); }