/src/NUnit/interfaces/Filters/NameFilter.cs
C# | 58 lines | 26 code | 7 blank | 25 comment | 2 complexity | 40e4fc59d0ee65fa52008142c75c4535 MD5 | raw file
Possible License(s): GPL-2.0
- // ****************************************************************
- // This is free software licensed under the NUnit license. You
- // may obtain a copy of the license as well as information regarding
- // copyright ownership at http://nunit.org.
- // ****************************************************************
-
- using System;
- using System.Collections;
-
- namespace NUnit.Core.Filters
- {
- /// <summary>
- /// Summary description for NameFilter.
- /// </summary>
- ///
- [Serializable]
- public class NameFilter : TestFilter
- {
- private ArrayList testNames = new ArrayList();
-
- /// <summary>
- /// Construct an empty NameFilter
- /// </summary>
- public NameFilter() { }
-
- /// <summary>
- /// Construct a NameFilter for a single TestName
- /// </summary>
- /// <param name="testName"></param>
- public NameFilter( TestName testName )
- {
- testNames.Add( testName );
- }
-
- /// <summary>
- /// Add a TestName to a NameFilter
- /// </summary>
- /// <param name="testName"></param>
- public void Add( TestName testName )
- {
- testNames.Add( testName );
- }
-
- /// <summary>
- /// Check if a test matches the filter
- /// </summary>
- /// <param name="test">The test to match</param>
- /// <returns>True if it matches, false if not</returns>
- public override bool Match( ITest test )
- {
- foreach( TestName testName in testNames )
- if ( test.TestName == testName )
- return true;
-
- return false;
- }
- }
- }