Example #1
0
        public void Search_CustomInspectorWithCollectionFilter_WhenCollectionIsIEnumerable_ReturnsFilteredResults()
        {
            var container = new TestDataContainerWithCustomInspector
            {
                SourceData      = Generate(100),
                DestinationData = new List <TestData>()
            };

            container.SourceData[0].StringEnumerable = new[]
            {
                "a", "b"
            };

            container.SourceData[1].StringEnumerable = new[]
            {
                "b", "c"
            };

            container.SourceData[2].StringEnumerable = new[]
            {
                "c", "d", "e"
            };

            m_PropertyElement.SetTarget(container);

            var searchElement = m_PropertyElement.Q <SearchElement>("filter");

            searchElement.Search("e:e");

            Assert.That(container.DestinationData.Count, Is.EqualTo(1));

            searchElement.Search("e:b");

            Assert.That(container.DestinationData.Count, Is.EqualTo(2));
        }
Example #2
0
        public void Search_CustomInspectorWithDataBindings_ReturnsFilteredResults()
        {
            var container = new TestDataContainerWithCustomInspector
            {
                SourceData      = Generate(100),
                DestinationData = new List <TestData>()
            };

            m_PropertyElement.SetTarget(container);

            var searchElement = m_PropertyElement.Q <SearchElement>("filter");
            var searchHandler = searchElement.GetUxmlSearchHandler();

            /* The UXML declaration of the search element is.
             *
             * <pui:SearchElement
             *      name="filter"
             *      search-delay="100"
             *      handler-type="sync"
             *      search-data="Id Name"
             *      source-data="SourceData"
             *      filtered-data="DestinationData"
             *      search-filters="a:StringArray"
             *      global-string-comparison="Ordinal"/>
             */

            Assert.That(searchElement.SearchDelay, Is.EqualTo(100));
            Assert.That(searchHandler.Mode, Is.EqualTo(SearchHandlerType.sync));
            Assert.That(searchHandler.SearchDataType, Is.EqualTo(typeof(TestData)));
            Assert.That(searchElement.GlobalStringComparison, Is.EqualTo(StringComparison.Ordinal));

            searchElement.Search("Mesh");

            Assert.That(container.DestinationData.Count, Is.EqualTo(25));
        }