(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / nunit20 / core / CategoryFilter.cs
blob57d55030fa268fd280373ba979f727440e0cdaef
1 using System;
2 using System.Collections;
4 namespace NUnit.Core
6 /// <summary>
7 /// Summary description for CategoryFilter.
8 /// </summary>
9 ///
10 [Serializable]
11 public class CategoryFilter : Filter
13 ArrayList categories;
15 public CategoryFilter() : this( false ) { }
17 public CategoryFilter( bool exclude ) : base( exclude )
19 categories = new ArrayList();
22 public CategoryFilter( string name ) : this( name, false ) { }
24 public CategoryFilter( string name, bool exclude ) : base( exclude )
26 categories = new ArrayList();
27 categories.Add( name );
30 public CategoryFilter( string[] names ) : this( names, false ) { }
32 public CategoryFilter( string[] names, bool exclude ) : base( exclude )
34 categories = new ArrayList();
35 categories.AddRange( names );
38 public void AddCategory(string name)
40 categories.Add( name );
43 #region IFilter Members
45 public override bool Pass(TestSuite suite)
47 // return CheckCategories( suite ) ? !Exclude : Exclude;
49 if ( categories.Count == 0 ) return true;
51 bool pass = Exclude;
53 if (CheckCategories(suite))
54 return !Exclude;
56 foreach (Test test in suite.Tests)
58 if ( test.Filter(this) == !Exclude )
60 pass=true;
61 break;
65 return pass;
68 public override bool Pass(TestCase test)
70 if ( categories.Count == 0 )
71 return true;
72 return CheckCategories( test ) ? !Exclude : Exclude ;
74 // if (CheckCategories(test.Parent))
75 // return true;
77 // return CheckCategories(test);
80 #endregion
82 /// <summary>
83 /// Method returns true if the test has a particular
84 /// category or if an ancestor test does. We don't
85 /// worry about whether this is an include or an
86 /// exclude filter at this point because only positive
87 /// categories are inherited, not their absence.
88 /// </summary>
89 private bool CheckCategories(Test test)
91 return test.HasCategory( categories )
92 || test.Parent != null
93 && test.Parent.HasCategory( categories );
95 // if (test.Categories != null)
96 // {
97 // foreach (string name in categories)
98 // {
99 // if (test.Categories.Contains(name))
100 // return true;
101 // }
102 // }
104 // return false;