FilterSet

We found 10 examples in language CSharp for this search. You will see 38 fragments of code.

        [Test]
        public void SimpleConstructor_WhenSuccessful_InitializesProperties()
        {
            var filter = new AnyFilter<object>();
            var filterSet = new FilterSet<object>(filter);

            Assert.Count(1, filterSet.Rules);
            Assert.AreEqual(FilterRuleType.Inclusion, filterSet.Rules[0].RuleType);
            Assert.AreEqual(filter, filterSet.Rules[0].Filter);
        }

        [Test]
        public void RulesConstructor_WhenSuccessful_InitializesProperties()
        {
            var filterRules = new[] { new FilterRule<object>(FilterRuleType.Exclusion, new AnyFilter<object>()), new FilterRule<object>(FilterRuleType.Inclusion, new NoneFilter<object>()) };
            var filterSet = new FilterSet<object>(filterRules);

            Assert.AreElementsEqual(filterRules, filterSet.Rules);
        }

        [Test]
        public void IsEmpty_WhenAtLeastOneRule_ReturnsFalse()
        {
            var filterSet = new FilterSet<object>(new AnyFilter<object>());

            Assert.IsFalse(filterSet.IsEmpty);
        }

        [Test]
        public void HasInclusionRules_WhenAtLeastOneInclusionRule_ReturnsTrue()
        {
            var filterSet = new FilterSet<object>(new AnyFilter<object>());

            Assert.IsTrue(filterSet.HasInclusionRules);
        }

        [Test]
        public void HasInclusionRules_WhenOnlyExclusionRules_ReturnsFalse()
        {
            var filterSet = new FilterSet<object>(new[] { new FilterRule<object>(FilterRuleType.Exclusion, new AnyFilter<object>()) });

            Assert.IsFalse(filterSet.HasInclusionRules);
        }


        /// <summary>
        /// Adds the elements of a <see cref="FilterSet"/> array to the end of the collection.
        /// </summary>
        /// <param name="items">The array of <see cref="FilterSet"/> elements to be added to the end of the collection.</param> 
        public void AddRange(FilterSet[] items) {
            for (int i = 0; (i < items.Length); i = (i + 1)) {
                Add(items[i]);
            }
        }
        
        /// <summary>
        /// Inserts a <see cref="FilterSet"/> into the collection at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
        /// <param name="item">The <see cref="FilterSet"/> to insert.</param>
        public void Insert(int index, FilterSet item) {
            base.List.Insert(index, item);
        }
        
        /// <summary>
        /// Removes a member from the collection.
        /// </summary>
        /// <param name="item">The <see cref="FilterSet"/> to remove from the collection.</param>
        public void Remove(FilterSet item) {
            base.List.Remove(item);
        }


        [Test]
        public void SimpleConstructor_WhenSuccessful_InitializesProperties()
        {
            var filter = new AnyFilter<object>();
            var filterSet = new FilterSet<object>(filter);

            Assert.Count(1, filterSet.Rules);
            Assert.AreEqual(FilterRuleType.Inclusion, filterSet.Rules[0].RuleType);
            Assert.AreEqual(filter, filterSet.Rules[0].Filter);
        }

        [Test]
        public void RulesConstructor_WhenSuccessful_InitializesProperties()
        {
            var filterRules = new[] { new FilterRule<object>(FilterRuleType.Exclusion, new AnyFilter<object>()), new FilterRule<object>(FilterRuleType.Inclusion, new NoneFilter<object>()) };
            var filterSet = new FilterSet<object>(filterRules);

            Assert.AreElementsEqual(filterRules, filterSet.Rules);
        }

        [Test]
        public void IsEmpty_WhenAtLeastOneRule_ReturnsFalse()
        {
            var filterSet = new FilterSet<object>(new AnyFilter<object>());

            Assert.IsFalse(filterSet.IsEmpty);
        }

        [Test]
        public void HasInclusionRules_WhenAtLeastOneInclusionRule_ReturnsTrue()
        {
            var filterSet = new FilterSet<object>(new AnyFilter<object>());

            Assert.IsTrue(filterSet.HasInclusionRules);
        }

        [Test]
        public void HasInclusionRules_WhenOnlyExclusionRules_ReturnsFalse()
        {
            var filterSet = new FilterSet<object>(new[] { new FilterRule<object>(FilterRuleType.Exclusion, new AnyFilter<object>()) });

            Assert.IsFalse(filterSet.HasInclusionRules);
        }


        [Test]
        public void SimpleConstructor_WhenSuccessful_InitializesProperties()
        {
            var filter = new AnyFilter<object>();
            var filterSet = new FilterSet<object>(filter);

            Assert.Count(1, filterSet.Rules);
            Assert.AreEqual(FilterRuleType.Inclusion, filterSet.Rules[0].RuleType);
            Assert.AreEqual(filter, filterSet.Rules[0].Filter);
        }

        [Test]
        public void RulesConstructor_WhenSuccessful_InitializesProperties()
        {
            var filterRules = new[] { new FilterRule<object>(FilterRuleType.Exclusion, new AnyFilter<object>()), new FilterRule<object>(FilterRuleType.Inclusion, new NoneFilter<object>()) };
            var filterSet = new FilterSet<object>(filterRules);

            Assert.AreElementsEqual(filterRules, filterSet.Rules);
        }

        [Test]
        public void IsEmpty_WhenAtLeastOneRule_ReturnsFalse()
        {
            var filterSet = new FilterSet<object>(new AnyFilter<object>());

            Assert.IsFalse(filterSet.IsEmpty);
        }

        [Test]
        public void HasInclusionRules_WhenAtLeastOneInclusionRule_ReturnsTrue()
        {
            var filterSet = new FilterSet<object>(new AnyFilter<object>());

            Assert.IsTrue(filterSet.HasInclusionRules);
        }

        [Test]
        public void HasInclusionRules_WhenOnlyExclusionRules_ReturnsFalse()
        {
            var filterSet = new FilterSet<object>(new[] { new FilterRule<object>(FilterRuleType.Exclusion, new AnyFilter<object>()) });

            Assert.IsFalse(filterSet.HasInclusionRules);
        }


        [Test]
        public void SimpleConstructor_WhenSuccessful_InitializesProperties()
        {
            var filter = new AnyFilter<object>();
            var filterSet = new FilterSet<object>(filter);

            Assert.Count(1, filterSet.Rules);
            Assert.AreEqual(FilterRuleType.Inclusion, filterSet.Rules[0].RuleType);
            Assert.AreEqual(filter, filterSet.Rules[0].Filter);
        }

        [Test]
        public void RulesConstructor_WhenSuccessful_InitializesProperties()
        {
            var filterRules = new[] { new FilterRule<object>(FilterRuleType.Exclusion, new AnyFilter<object>()), new FilterRule<object>(FilterRuleType.Inclusion, new NoneFilter<object>()) };
            var filterSet = new FilterSet<object>(filterRules);

            Assert.AreElementsEqual(filterRules, filterSet.Rules);
        }

        [Test]
        public void IsEmpty_WhenAtLeastOneRule_ReturnsFalse()
        {
            var filterSet = new FilterSet<object>(new AnyFilter<object>());

            Assert.IsFalse(filterSet.IsEmpty);
        }

        [Test]
        public void HasInclusionRules_WhenAtLeastOneInclusionRule_ReturnsTrue()
        {
            var filterSet = new FilterSet<object>(new AnyFilter<object>());

            Assert.IsTrue(filterSet.HasInclusionRules);
        }

        [Test]
        public void HasInclusionRules_WhenOnlyExclusionRules_ReturnsFalse()
        {
            var filterSet = new FilterSet<object>(new[] { new FilterRule<object>(FilterRuleType.Exclusion, new AnyFilter<object>()) });

            Assert.IsFalse(filterSet.HasInclusionRules);
        }


        [Test]
        public void Generated_filter_should_be_empty_if_tree_model_root_is_null()
        {
            var filterSet = filterService.GenerateFilterSetFromSelectedTests();

            Assert.IsTrue(filterSet.IsEmpty);
        }

        [Test]
        public void Generated_filter_should_be_empty_if_tree_model_root_is_checked()
        {
            var testTreeNode = new TestTreeNode("root", "root")
            {
                CheckState = CheckState.Checked
            };
            testTreeModel.Stub(ttm => ttm.Root).Return(testTreeNode);

            var filterSet = filterService.GenerateFilterSetFromSelectedTests();

            Assert.IsTrue(filterSet.IsEmpty);
        }


        [Test]
        public void SimpleConstructor_WhenSuccessful_InitializesProperties()
        {
            var filter = new AnyFilter<object>();
            var filterSet = new FilterSet<object>(filter);

            Assert.Count(1, filterSet.Rules);
            Assert.AreEqual(FilterRuleType.Inclusion, filterSet.Rules[0].RuleType);
            Assert.AreEqual(filter, filterSet.Rules[0].Filter);
        }

        [Test]
        public void RulesConstructor_WhenSuccessful_InitializesProperties()
        {
            var filterRules = new[] { new FilterRule<object>(FilterRuleType.Exclusion, new AnyFilter<object>()), new FilterRule<object>(FilterRuleType.Inclusion, new NoneFilter<object>()) };
            var filterSet = new FilterSet<object>(filterRules);

            Assert.AreElementsEqual(filterRules, filterSet.Rules);
        }

        [Test]
        public void IsEmpty_WhenAtLeastOneRule_ReturnsFalse()
        {
            var filterSet = new FilterSet<object>(new AnyFilter<object>());

            Assert.IsFalse(filterSet.IsEmpty);
        }

        [Test]
        public void HasInclusionRules_WhenAtLeastOneInclusionRule_ReturnsTrue()
        {
            var filterSet = new FilterSet<object>(new AnyFilter<object>());

            Assert.IsTrue(filterSet.HasInclusionRules);
        }

        [Test]
        public void HasInclusionRules_WhenOnlyExclusionRules_ReturnsFalse()
        {
            var filterSet = new FilterSet<object>(new[] { new FilterRule<object>(FilterRuleType.Exclusion, new AnyFilter<object>()) });

            Assert.IsFalse(filterSet.HasInclusionRules);
        }


        public void ApplyFilterSet(FilterSet<ITestDescriptor> filterSet)
        {
            if (testTreeModel.Root == null)
                return;

            var root = testTreeModel.Root;

            if (filterSet.IsEmpty)
            {
                root.CheckState = CheckState.Checked;
            }
            else
            {
                ApplyFilters(root, filterSet);
            }
        }

        private static void ApplyFilters(Node node, FilterSet<ITestDescriptor> filterSet)
        {
            if (node is ITestDescriptor)
            {
                var match = EvaluateNode(node, filterSet);
                if (match) return;
            }
         
            foreach (var child in node.Nodes)
            {
                ApplyFilters(child, filterSet);
            }
        }

        private static bool EvaluateNode(Node node, FilterSet<ITestDescriptor> filterSet)
        {
            var result = filterSet.Evaluate((ITestDescriptor)node);

            if (result == FilterSetResult.Include)
            {
                node.CheckState = CheckState.Checked;
                return true;
            }
            
            node.CheckState = CheckState.Unchecked;
            return false;
        }


        [Test]
        public void If_applied_filter_set_is_none_filter_then_the_root_should_be_unchecked()
        {
            var testTreeNode = new TestTreeNode("root", "root");
            testTreeModel.Stub(ttm => ttm.Root).Return(testTreeNode);
            var filterSet = new FilterSet<ITestDescriptor>(new NoneFilter<ITestDescriptor>());

            filterService.ApplyFilterSet(filterSet);

            Assert.AreEqual(CheckState.Unchecked, testTreeNode.CheckState);
        }

        [Test]
        public void Generated_filter_should_be_empty_if_tree_model_root_is_null()
        {
            var filterSet = filterService.GenerateFilterSetFromSelectedTests();

            Assert.IsTrue(filterSet.IsEmpty);
        }

        [Test]
        public void Generated_filter_should_be_empty_if_tree_model_root_is_checked()
        {
            var testTreeNode = new TestTreeNode("root", "root")
            {
                CheckState = CheckState.Checked
            };
            testTreeModel.Stub(ttm => ttm.Root).Return(testTreeNode);

            var filterSet = filterService.GenerateFilterSetFromSelectedTests();

            Assert.IsTrue(filterSet.IsEmpty);
        }


        [Test]
        public void Generated_filter_should_be_empty_if_tree_model_root_is_null()
        {
            var filterSet = filterService.GenerateFilterSetFromSelectedTests();

            Assert.IsTrue(filterSet.IsEmpty);
        }

        [Test]
        public void Generated_filter_should_be_empty_if_tree_model_root_is_checked()
        {
            var testTreeNode = new TestTreeNode("root", "root")
            {
                CheckState = CheckState.Checked
            };
            testTreeModel.Stub(ttm => ttm.Root).Return(testTreeNode);

            var filterSet = filterService.GenerateFilterSetFromSelectedTests();

            Assert.IsTrue(filterSet.IsEmpty);
        }

Microsoft.Azure.Amqp.Framing.FilterSet : IEnumerable

Constructors :

public FilterSet()

Methods :

public Object get_Item(AmqpSymbol key = )
public Void set_Item(AmqpSymbol key = , Object value = )
public Object get_Item(MapKey key = )
public Void set_Item(MapKey key = , Object value = )
public Boolean TryGetValue(AmqpSymbol key = , TValue& value = )
public Boolean TryGetValue(MapKey key = , TValue& value = )
public Boolean TryRemoveValue(AmqpSymbol key = , TValue& value = )
public Void Add(AmqpSymbol key = , Object value = )
public Void Add(MapKey key = , Object value = )
public Void Merge(RestrictedMap<AmqpSymbol> map = )
public Void SetMap(AmqpMap map = )
public String ToString()
public IEnumerator<KeyValuePair<MapKey, Object>> GetEnumerator()
public Type GetType()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()