private bool ApplyTraitFilter(ITestCase testCase, Func <bool, bool>?reportFilteredTest = null) { Func <bool, bool> log = (result) => reportFilteredTest?.Invoke(result) ?? result; if (!testCase.HasTraits()) { return(log(!Exclude)); } if (testCase.TryGetTrait(SelectorName !, out var values)) { if (values == null || values.Count == 0) { // We have no values and the filter doesn't specify one - that means we match on // the trait name only. if (string.IsNullOrEmpty(SelectorValue)) { return(log(Exclude)); } return(log(!Exclude)); } return(values.Any(value => value.Equals(SelectorValue, StringComparison.InvariantCultureIgnoreCase)) ? log(Exclude) : log(!Exclude)); } // no traits found, that means that we return the opposite of the setting of the filter return(log(!Exclude)); }