Inheritance: ViewModelBase
Beispiel #1
0
        private static bool TestCaseMatches(TestCaseViewModel testCase, SearchQuery searchQuery)
        {
            if (testCase.DisplayName.IndexOf(searchQuery.SearchString, StringComparison.CurrentCultureIgnoreCase) < 0)
            {
                return(false);
            }

            if (searchQuery.TraitSet.Count > 0)
            {
                var anyMatch = false;
                foreach (var cur in testCase.Traits)
                {
                    if (searchQuery.TraitSet.Contains(cur))
                    {
                        anyMatch = true;
                        break;
                    }
                }

                if (!anyMatch)
                {
                    return(false);
                }
            }

            var noFilter = !(searchQuery.FilterFailedTests | searchQuery.FilterPassedTests | searchQuery.FilterSkippedTests);

            switch (testCase.State)
            {
            case TestState.Passed:
                return(noFilter || searchQuery.FilterPassedTests);

            case TestState.Skipped:
                return(noFilter || searchQuery.FilterSkippedTests);

            case TestState.Failed:
                return(noFilter || searchQuery.FilterFailedTests);

            case TestState.NotRun:
                return(noFilter);

            default:
                Debug.Assert(false, "What state is this test case in?");
                return(true);
            }
        }
Beispiel #2
0
        private void OnTestsDiscovered(IEnumerable <TestCaseData> testCases)
        {
            var traitWorkerList = new List <TraitViewModel>();

            foreach (var testCase in testCases)
            {
                traitWorkerList.Clear();

                // Get or create traits.
                if (testCase.TraitMap?.Count > 0)
                {
                    foreach (var kvp in testCase.TraitMap)
                    {
                        var name   = kvp.Key;
                        var values = kvp.Value;

                        var parentTraitViewModel = traitCollectionView.GetOrAdd(name);

                        foreach (var value in values)
                        {
                            var traitViewModel = parentTraitViewModel.GetOrAdd(value);
                            traitWorkerList.Add(traitViewModel);
                        }
                    }
                }

                var testCaseViewModel = new TestCaseViewModel(
                    testCase.DisplayName,
                    testCase.SkipReason,
                    testCase.AssemblyPath,
                    traitWorkerList);

                if (testCaseViewModel.State == TestState.Skipped)
                {
                    TestsSkipped++;
                }

                this.allTestCases.Add(testCaseViewModel);
            }
        }