PageRenderTime 45ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  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. using System;
  7. using System.Collections;
  8. namespace NUnit.Core.Filters
  9. {
  10. /// <summary>
  11. /// Summary description for NameFilter.
  12. /// </summary>
  13. ///
  14. [Serializable]
  15. public class NameFilter : TestFilter
  16. {
  17. private ArrayList testNames = new ArrayList();
  18. /// <summary>
  19. /// Construct an empty NameFilter
  20. /// </summary>
  21. public NameFilter() { }
  22. /// <summary>
  23. /// Construct a NameFilter for a single TestName
  24. /// </summary>
  25. /// <param name="testName"></param>
  26. public NameFilter( TestName testName )
  27. {
  28. testNames.Add( testName );
  29. }
  30. /// <summary>
  31. /// Add a TestName to a NameFilter
  32. /// </summary>
  33. /// <param name="testName"></param>
  34. public void Add( TestName testName )
  35. {
  36. testNames.Add( testName );
  37. }
  38. /// <summary>
  39. /// Check if a test matches the filter
  40. /// </summary>
  41. /// <param name="test">The test to match</param>
  42. /// <returns>True if it matches, false if not</returns>
  43. public override bool Match( ITest test )
  44. {
  45. foreach( TestName testName in testNames )
  46. if ( test.TestName == testName )
  47. return true;
  48. return false;
  49. }
  50. }
  51. }