/src/NUnit/interfaces/Filters/NameFilter.cs
C# | 58 lines | 26 code | 7 blank | 25 comment | 2 complexity | 40e4fc59d0ee65fa52008142c75c4535 MD5 | raw file
1// **************************************************************** 2// This is free software licensed under the NUnit license. You 3// may obtain a copy of the license as well as information regarding 4// copyright ownership at http://nunit.org. 5// **************************************************************** 6 7using System; 8using System.Collections; 9 10namespace NUnit.Core.Filters 11{ 12 /// <summary> 13 /// Summary description for NameFilter. 14 /// </summary> 15 /// 16 [Serializable] 17 public class NameFilter : TestFilter 18 { 19 private ArrayList testNames = new ArrayList(); 20 21 /// <summary> 22 /// Construct an empty NameFilter 23 /// </summary> 24 public NameFilter() { } 25 26 /// <summary> 27 /// Construct a NameFilter for a single TestName 28 /// </summary> 29 /// <param name="testName"></param> 30 public NameFilter( TestName testName ) 31 { 32 testNames.Add( testName ); 33 } 34 35 /// <summary> 36 /// Add a TestName to a NameFilter 37 /// </summary> 38 /// <param name="testName"></param> 39 public void Add( TestName testName ) 40 { 41 testNames.Add( testName ); 42 } 43 44 /// <summary> 45 /// Check if a test matches the filter 46 /// </summary> 47 /// <param name="test">The test to match</param> 48 /// <returns>True if it matches, false if not</returns> 49 public override bool Match( ITest test ) 50 { 51 foreach( TestName testName in testNames ) 52 if ( test.TestName == testName ) 53 return true; 54 55 return false; 56 } 57 } 58}