Esempio n. 1
0
        public void TestCriteriaSearcher()
        {
            var selectedItem = m_Sources.Find(BinaryOperatorKind.Equals.ToString());

            var selectedComponent = TypeHandle.Unknown;
            var selectedMember    = new TypeMember();
            var selectedOperator  = BinaryOperatorKind.Xor;

            void Callback(TypeHandle handle, TypeMember member, BinaryOperatorKind kind)
            {
                selectedComponent = handle;
                selectedMember    = member;
                selectedOperator  = kind;
            }

            var onItemSelected = typeof(EcsSearcherServices).GetMethod("OnItemSelected", BindingFlags.Static | BindingFlags.NonPublic);

            onItemSelected?.Invoke(null, new object[]
            {
                selectedItem,
                (Action <TypeHandle, TypeMember, BinaryOperatorKind>)Callback
            });

            var dummyComponent = typeof(DummyTestComponent).GenerateTypeHandle(m_Stencil);

            Assert.AreEqual(dummyComponent, selectedComponent);
            Assert.AreEqual(selectedOperator, BinaryOperatorKind.Equals);
            Assert.AreEqual(selectedMember.Type, typeof(float).GenerateTypeHandle(m_Stencil));
            Assert.That(selectedMember.Path, Is.EqualTo(new List <string> {
                "Value", "x"
            }));
        }
Esempio n. 2
0
        public void TestFind_Null()
        {
            var parent = new SearcherItem("parent");
            var child  = parent.Find("child");

            Assert.IsNull(child);
        }
Esempio n. 3
0
        public void TestFind_NotNull()
        {
            var parent = new SearcherItem("parent");

            parent.AddChild(new SearcherItem("child"));

            var child = parent.Find("child");

            Assert.NotNull(child);
            Assert.AreEqual(child.Name, "child");
        }
Esempio n. 4
0
        public void TestFind_Recursive()
        {
            var parent = new SearcherItem("parent", "", new List <SearcherItem>
            {
                new SearcherItem("a", "", new List <SearcherItem>
                {
                    new SearcherItem("aa1"),
                    new SearcherItem("aa2")
                }),
                new SearcherItem("b", "", new List <SearcherItem>
                {
                    new SearcherItem("bb1"),
                    new SearcherItem("bb2")
                })
            });

            var found = parent.Find("bb1");

            Assert.NotNull(found);
            Assert.AreEqual(found.Name, "bb1");
        }