public override IEnumerable <TestingSearchResultItem> GetHistoricalTests(DataUri hostItemDataUri = null, string searchText = null)
        {
            TestingSearch testingSearch = new TestingSearch();

            if (hostItemDataUri != null)
            {
                testingSearch.HostItem = hostItemDataUri;
            }
            if (!string.IsNullOrEmpty(searchText))
            {
                testingSearch.SearchText = searchText;
            }
            IEnumerable <TestingSearchResultItem> stoppedTests = testingSearch.GetStoppedTests();
            List <TestingSearchResultItem>        list         = new List <TestingSearchResultItem>();

            foreach (TestingSearchResultItem item2 in stoppedTests)
            {
                if (item2.Uri != null)
                {
                    Item item = Database.GetItem(item2.Uri);
                    if (item != null)
                    {
                        TestDefinitionItem testDefinitionItem = TestDefinitionItem.Create(item);
                        if (testDefinitionItem != null && testDefinitionItem.IsFinished)
                        {
                            list.Add(item2);
                        }
                    }
                }
            }
            return(list);
        }
        public override IEnumerable <TestingSearchResultItem> GetActiveTests(DataUri hostItemDataUri = null, string searchText = null, ID deviceId = null)
        {
            TestingSearch testingSearch      = new TestingSearch();
            ISearchIndex  testingSearchIndex = Sitecore.ContentTesting.ContentSearch.TestingSearch.GetTestingSearchIndex();

            if (testingSearchIndex == null)
            {
                return(Enumerable.Empty <TestingSearchResultItem>());
            }
            int num = 0;

            while (IndexCustodian.IsRebuilding(testingSearchIndex) && num < 10)
            {
                Thread.Sleep(200);
                num++;
            }
            if (hostItemDataUri != null)
            {
                testingSearch.HostItem = hostItemDataUri;
            }
            if (!string.IsNullOrEmpty(searchText))
            {
                testingSearch.SearchText = searchText;
            }
            if (deviceId != (ID)null)
            {
                testingSearch.DeviceId = deviceId;
            }
            return(testingSearch.GetRunningTests());
        }