public void TestObjectManagerShow()
        {
            ObjectManager.AddChild(new MockComponent(), true, true);
            ObjectManager.AddChild(new MockComponent(), true, true);

            ObjectManager.Update(0);

            ObjectManager.Hide();

            // Not for children
            {
                ObjectManager.Show(false);

                ObjectManager.CheckAlive();

                foreach (Component component in ObjectManager)
                {
                    component.CheckHidden();
                }
            }

            // For children
            {
                ObjectManager.Show();

                ObjectManager.CheckAlive();

                foreach (Component component in ObjectManager)
                {
                    component.CheckAlive();
                }
            }
        }
Exemplo n.º 2
0
        public void TestBaseObjectPreviousSibling()
        {
            ObjectManager <MockBaseObject> objectManager = new ObjectManager <MockBaseObject>();

            MockBaseObject object1 = new MockBaseObject();
            MockBaseObject object2 = new MockBaseObject();
            MockBaseObject object3 = new MockBaseObject();
            MockBaseObject object4 = new MockBaseObject();

            objectManager.AddChild(object1);

            object1.AddChild(object2);
            object1.AddChild(object3);
            object1.AddChild(object4);

            objectManager.Update(0);

            Assert.IsFalse(object1.HasPreviousSibling);
            Assert.IsFalse(object2.HasPreviousSibling);
            Assert.IsTrue(object3.HasPreviousSibling);
            Assert.IsTrue(object4.HasPreviousSibling);

            Assert.AreEqual(object2, object3.PreviousSibling);
            Assert.AreEqual(object3, object4.PreviousSibling);
        }
        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 TestObjectManagerAddingInitialChildren()
        {
            ObjectManager = new ObjectManager <Component>();

            ObjectManager.AddChild(new MockComponent());
            ObjectManager.AddChild(new MockComponent());

            Assert.AreEqual(0, ObjectManager.ActiveObjectsCount);

            foreach (Component component in ObjectManager)
            {
                component.CheckAlive();
            }

            ObjectManager.LoadContent();
            ObjectManager.Initialise();

            Assert.AreEqual(2, ObjectManager.ActiveObjectsCount);
        }
        public void TestObjectManagerLastChild()
        {
            Component component1 = new MockComponent();
            Component component2 = new MockComponent();

            ObjectManager.AddChild(component1, true, true);
            ObjectManager.AddChild(component2, true, true);

            ObjectManager.Update(0);

            Assert.AreEqual(component2, ObjectManager.LastChild <Component>());
        }
        public void TestObjectManagerDie()
        {
            ObjectManager.AddChild(new MockComponent());
            ObjectManager.AddChild(new MockComponent());

            ObjectManager.Die();

            ObjectManager.CheckDead();

            foreach (Component component in ObjectManager)
            {
                component.CheckDead();
            }
        }
        public void TestObjectManagerAddingChildren()
        {
            ObjectManager.AddChild(new MockComponent(), true, true);
            ObjectManager.AddChild(new MockComponent(), true, true);
            ObjectManager.AddChild(new MockComponent(), true, true);

            ObjectManager.Update(0);

            foreach (Component component in ObjectManager)
            {
                component.CheckAlive();
            }

            Assert.AreEqual(3, ObjectManager.ActiveObjectsCount);
        }
        public void TestObjectManagerExtractChild()
        {
            Component component1 = ObjectManager.AddChild(new MockComponent(), true, true);
            Component component2 = ObjectManager.AddChild(new MockComponent(), true, true);

            ObjectManager.ExtractChild(component1);
            ObjectManager.ExtractChild(component2);

            ObjectManager.Update(0);

            component1.CheckAlive();
            component2.CheckAlive();

            Assert.AreEqual(0, ObjectManager.ActiveObjectsCount);
        }
        public void TestObjectManagerChildAtIndex()
        {
            MockComponent object1 = new MockComponent();
            MockComponent object2 = new MockComponent();
            MockComponent object3 = new MockComponent();
            MockComponent object4 = new MockComponent();

            ObjectManager.AddChild(object1, true, true);
            ObjectManager.AddChild(object2, true, true);
            ObjectManager.AddChild(object3, true, true);
            ObjectManager.AddChild(object4, true, true);

            ObjectManager.Update(0);

            Assert.AreEqual(object1, ObjectManager.ChildAtIndex(0));
            Assert.AreEqual(object2, ObjectManager.ChildAtIndex(1));
            Assert.AreEqual(object3, ObjectManager.ChildAtIndex(2));
            Assert.AreEqual(object4, ObjectManager.ChildAtIndex(3));
        }
        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)));
        }