// **************************************************************** // Copyright 2007, Charlie Poole // This is free software licensed under the NUnit license. You may // obtain a copy of the license at http://nunit.org/?p=license&r=2.4 // **************************************************************** using System; using System.Collections; namespace NUnit.Core.Filters { /// /// Combines multiple filters so that a test must pass one /// of them in order to pass this filter. /// [Serializable] public class OrFilter : TestFilter { private ArrayList filters = new ArrayList(); /// /// Constructs an empty OrFilter /// public OrFilter() { } /// /// Constructs an AndFilter from an array of filters /// /// public OrFilter( params ITestFilter[] filters ) { this.filters.AddRange( filters ); } /// /// Adds a filter to the list of filters /// /// The filter to be added public void Add( ITestFilter filter ) { this.filters.Add( filter ); } /// /// Return an array of the composing filters /// public ITestFilter[] Filters { get { return (ITestFilter[])filters.ToArray(typeof(ITestFilter)); } } /// /// Checks whether the OrFilter is matched by a test /// /// The test to be matched /// True if any of the component filters pass, otherwise false public override bool Pass( ITest test ) { foreach( ITestFilter filter in filters ) if ( filter.Pass( test ) ) return true; return false; } /// /// Checks whether the OrFilter is matched by a test /// /// The test to be matched /// True if any of the component filters match, otherwise false public override bool Match( ITest test ) { foreach( ITestFilter filter in filters ) if ( filter.Match( test ) ) return true; return false; } } }