public void TestObjectManagerGetChildrenOfType() { Component component1 = ObjectManager.AddChild(new MockComponent(), true, true); MockInheritedComponent inheritedComponent = ObjectManager.AddChild(new MockInheritedComponent(), true, true); ObjectManager.Update(0); Assert.AreEqual(2, ObjectManager.ActiveObjectsCount); List <Component> expectedList = new List <Component>() { component1, inheritedComponent }; List <Component> actualList = ObjectManager.GetChildrenOfType <Component>(); Assert.IsTrue(expectedList.CheckOrderedListsEqual(actualList)); List <MockInheritedComponent> expectedInheritedList = new List <MockInheritedComponent>() { inheritedComponent }; List <MockInheritedComponent> actualInheritedList = ObjectManager.GetChildrenOfType <MockInheritedComponent>(); Assert.IsTrue(expectedInheritedList.CheckOrderedListsEqual(actualInheritedList)); }
public void TestObjectManagerFindChild() { Component component1 = ObjectManager.AddChild(new MockComponent(), true, true); component1.Name = "TestComponent1"; Component component2 = ObjectManager.AddChild(new MockComponent(), true, true); component2.Name = "TestComponent2"; MockInheritedComponent testInheritedComponent = ObjectManager.AddChild(new MockInheritedComponent(), true, true); testInheritedComponent.Name = "TestInheritedComponent"; ObjectManager.Update(0); Assert.AreEqual(component1, ObjectManager.FindChild <Component>(x => x.Name == "TestComponent1")); Assert.AreEqual(component2, ObjectManager.FindChild <Component>(x => x == component2)); Assert.AreEqual(testInheritedComponent, ObjectManager.FindChild <MockInheritedComponent>(x => (x.Name == "TestInheritedComponent" || x == testInheritedComponent))); }
public void TestObjectManagerChildExists() { Component component1 = ObjectManager.AddChild(new MockComponent(), true, true); component1.Name = "TestComponent1"; Component component2 = ObjectManager.AddChild(new MockComponent(), true, true); component2.Name = "TestComponent2"; MockInheritedComponent testInheritedComponent = ObjectManager.AddChild(new MockInheritedComponent(), true, true); testInheritedComponent.Name = "TestInheritedComponent"; ObjectManager.Update(0); Assert.IsTrue(ObjectManager.Exists(x => x.Name == "TestComponent1")); Assert.IsTrue(ObjectManager.Exists(x => x == component2)); Assert.IsTrue(ObjectManager.Exists(x => (x.Name == "TestInheritedComponent" || x == testInheritedComponent))); Assert.IsFalse(ObjectManager.Exists(x => (x.Name == "NonExistentChild"))); Assert.IsFalse(ObjectManager.Exists(x => (x.Name == "TestInheritedComponent" && x != testInheritedComponent))); }