Filters

Namespace: Suave
We found 10 examples in language CSharp for this search. You will see 30 fragments of code.
        public static Filter CombineNot(Filter filter)
        {
			var notFilter = filter as NotFilter;

			if (notFilter != null)
			{
				return notFilter.Not;
			}

			return new NotFilter { Not = filter };
        }

        public static Filter CombineAnd(params Filter[] filters)
        {
            return Combine(combinedFilters => new AndFilter { And = combinedFilters }, filter => filter.And, filters);
        }

        public static Filter CombineOr(params Filter[] filters)
        {
            return Combine(combinedFilters => new OrFilter { Or = combinedFilters }, filter => filter.Or, filters);
        }

        private static Filter Combine<TFilter>(Func<List<Filter>, TFilter> combine, Func<TFilter, IEnumerable<Filter>> subFilters, params Filter[] filters)
            where TFilter : Filter
        {
            List<Filter> combinedFilters = new List<Filter>();

            foreach (var filter in filters)
            {
                if (filter != null)
                {
                    if (filter is TFilter)
                    {
                        combinedFilters.AddRange(subFilters(filter as TFilter));
                    }
                    else
                    {
                        combinedFilters.Add(filter);
                    }
                }
            }

            if (combinedFilters.Count == 0)
            {
                return null;
            }
            else if (combinedFilters.Count == 1)
            {
                return combinedFilters[0];
            }
            else
            {
                return combine(combinedFilters);
            }
        }

        [Fact]
        public void ActionFilters_ReturnsEmptyArray_WhenFiltersIsEmpty()
        {
            // Arrange
            IEnumerable<FilterInfo> filters = CreateEmptyFilters();
            FilterGrouping product = CreateProductUnderTest(filters);

            // Act
            IActionFilter[] actionFilters = product.ActionFilters;
            
            // Assert
            Assert.NotNull(actionFilters);
            Assert.Equal(0, actionFilters.Length);
        }

        [Fact]
        public void ActionFilters_ReturnsActionFilters()
        {
            // Arrange
            IActionFilter expectedGlobalFilter = CreateDummyActionFilter();
            FilterInfo globalFilter = new FilterInfo(expectedGlobalFilter, FilterScope.Global);
            IActionFilter expectedControllerFilter = CreateDummyActionFilter();
            FilterInfo controllerFilter = new FilterInfo(expectedControllerFilter, FilterScope.Controller);
            IActionFilter expectedActionFilter = CreateDummyActionFilter();
            FilterInfo actionFilter = new FilterInfo(expectedActionFilter, FilterScope.Action);
            IEnumerable<FilterInfo> filters = new FilterInfo[] { globalFilter, controllerFilter, actionFilter };
            FilterGrouping product = CreateProductUnderTest(filters);

            // Act
            IActionFilter[] actionFilters = product.ActionFilters;

            // Assert
            Assert.NotNull(actionFilters);
            Assert.Equal(3, actionFilters.Length);
            Assert.Same(expectedGlobalFilter, actionFilters[0]);
            Assert.Same(expectedControllerFilter, actionFilters[1]);
            Assert.Same(expectedActionFilter, actionFilters[2]);
        }

        [Fact]
        public void ActionFilters_ReturnsAllActionFilters_WhenOverrideScopeIsGlobal()
        {
            // Arrange
            IActionFilter expectedGlobalFilter = CreateDummyActionFilter();
            FilterInfo globalFilter = new FilterInfo(expectedGlobalFilter, FilterScope.Global);
            IActionFilter expectedControllerFilter = CreateDummyActionFilter();
            FilterInfo controllerFilter = new FilterInfo(expectedControllerFilter, FilterScope.Controller);
            IActionFilter expectedActionFilter = CreateDummyActionFilter();
            FilterInfo actionFilter = new FilterInfo(expectedActionFilter, FilterScope.Action);
            FilterInfo overrideFilter = new FilterInfo(CreateOverride(typeof(IActionFilter)), FilterScope.Global);
            IEnumerable<FilterInfo> filters = new FilterInfo[] { globalFilter, controllerFilter, actionFilter, overrideFilter };
            FilterGrouping product = CreateProductUnderTest(filters);

            // Act
            IActionFilter[] actionFilters = product.ActionFilters;

            // Assert
            Assert.NotNull(actionFilters);
            Assert.Equal(3, actionFilters.Length);
            Assert.Same(expectedGlobalFilter, actionFilters[0]);
            Assert.Same(expectedControllerFilter, actionFilters[1]);
            Assert.Same(expectedActionFilter, actionFilters[2]);
        }

        [Fact]
        public void ActionFilters_ReturnsControllerAndBelowActionFilters_WhenOverrideScopeIsController()
        {
            // Arrange
            IActionFilter expectedGlobalFilter = CreateDummyActionFilter();
            FilterInfo globalFilter = new FilterInfo(expectedGlobalFilter, FilterScope.Global);
            IActionFilter expectedControllerFilter = CreateDummyActionFilter();
            FilterInfo controllerFilter = new FilterInfo(expectedControllerFilter, FilterScope.Controller);
            IActionFilter expectedActionFilter = CreateDummyActionFilter();
            FilterInfo actionFilter = new FilterInfo(expectedActionFilter, FilterScope.Action);
            FilterInfo overrideFilter = new FilterInfo(CreateOverride(typeof(IActionFilter)), FilterScope.Controller);
            IEnumerable<FilterInfo> filters = new FilterInfo[] { globalFilter, controllerFilter, actionFilter, overrideFilter };
            FilterGrouping product = CreateProductUnderTest(filters);

            // Act
            IActionFilter[] actionFilters = product.ActionFilters;

            // Assert
            Assert.NotNull(actionFilters);
            Assert.Equal(2, actionFilters.Length);
            Assert.Same(expectedControllerFilter, actionFilters[0]);
            Assert.Same(expectedActionFilter, actionFilters[1]);
        }

        [Fact]
        public void ActionFilters_ReturnsActionScopeActionFilters_WhenOverrideScopeIsAction()
        {
            // Arrange
            IActionFilter expectedGlobalFilter = CreateDummyActionFilter();
            FilterInfo globalFilter = new FilterInfo(expectedGlobalFilter, FilterScope.Global);
            IActionFilter expectedControllerFilter = CreateDummyActionFilter();
            FilterInfo controllerFilter = new FilterInfo(expectedControllerFilter, FilterScope.Controller);
            IActionFilter expectedActionFilter = CreateDummyActionFilter();
            FilterInfo actionFilter = new FilterInfo(expectedActionFilter, FilterScope.Action);
            FilterInfo overrideFilter = new FilterInfo(CreateOverride(typeof(IActionFilter)), FilterScope.Action);
            IEnumerable<FilterInfo> filters = new FilterInfo[] { globalFilter, controllerFilter, actionFilter, overrideFilter };
            FilterGrouping product = CreateProductUnderTest(filters);

            // Act
            IActionFilter[] actionFilters = product.ActionFilters;

            // Assert
            Assert.NotNull(actionFilters);
            Assert.Equal(1, actionFilters.Length);
            Assert.Same(expectedActionFilter, actionFilters[0]);
        }

        [Fact]
        public void ActionFilters_ReturnsAllActionFilters_WhenOtherFilterIsOverriddenAtActionLevel()
        {
            // Arrange
            IActionFilter expectedGlobalFilter = CreateDummyActionFilter();
            FilterInfo globalFilter = new FilterInfo(expectedGlobalFilter, FilterScope.Global);
            IActionFilter expectedControllerFilter = CreateDummyActionFilter();
            FilterInfo controllerFilter = new FilterInfo(expectedControllerFilter, FilterScope.Controller);
            IActionFilter expectedActionFilter = CreateDummyActionFilter();
            FilterInfo actionFilter = new FilterInfo(expectedActionFilter, FilterScope.Action);
            FilterInfo overrideFilter = new FilterInfo(CreateOverride(typeof(object)), FilterScope.Action);
            IEnumerable<FilterInfo> filters = new FilterInfo[] { globalFilter, controllerFilter, actionFilter, overrideFilter };
            FilterGrouping product = CreateProductUnderTest(filters);

            // Act
            IActionFilter[] actionFilters = product.ActionFilters;

            // Assert
            Assert.NotNull(actionFilters);
            Assert.Equal(3, actionFilters.Length);
            Assert.Same(expectedGlobalFilter, actionFilters[0]);
            Assert.Same(expectedControllerFilter, actionFilters[1]);
            Assert.Same(expectedActionFilter, actionFilters[2]);
        }

        [Fact]
        public void Constructor_Default()
        {
            // Arrange + Act
            FilterInfo filterInfo = new FilterInfo();

            // Assert
            Assert.Empty(filterInfo.ActionFilters);
            Assert.Empty(filterInfo.AuthorizationFilters);
            Assert.Empty(filterInfo.AuthenticationFilters);
            Assert.Empty(filterInfo.ExceptionFilters);
            Assert.Empty(filterInfo.ResultFilters);
        }

        [Fact]
        public void Constructor_PopulatesFilterCollections()
        {
            // Arrange
            IActionFilter expectedActionFilter = CreateDummyActionFilter();
            IAuthorizationFilter expectedAuthorizationFilter = CreateDummyAuthorizationFilter();
            IAuthenticationFilter expectedAuthenticationFilter = CreateDummyAuthenticationFilter();
            IExceptionFilter expectedExceptionFilter = CreateDummyExceptionFilter();
            IResultFilter expectedResultFilter = CreateDummyResultFilter();

            List<Filter> filters = new List<Filter>()
            {
                CreateFilter(expectedActionFilter),
                CreateFilter(expectedAuthorizationFilter),
                CreateFilter(expectedAuthenticationFilter),
                CreateFilter(expectedExceptionFilter),
                CreateFilter(expectedResultFilter),
            };

            // Act
            FilterInfo filterInfo = new FilterInfo(filters);

            // Assert
            Assert.Same(expectedActionFilter, filterInfo.ActionFilters.SingleOrDefault());
            Assert.Same(expectedAuthorizationFilter, filterInfo.AuthorizationFilters.SingleOrDefault());
            Assert.Same(expectedAuthenticationFilter, filterInfo.AuthenticationFilters.SingleOrDefault());
            Assert.Same(expectedExceptionFilter, filterInfo.ExceptionFilters.SingleOrDefault());
            Assert.Same(expectedResultFilter, filterInfo.ResultFilters.SingleOrDefault());
        }

        [Fact]
        public void Constructor_IteratesOverFiltersOnlyOnce()
        {
            // Arrange
            var filtersMock = new Mock<IEnumerable<Filter>>();
            filtersMock.Setup(f => f.GetEnumerator()).Returns(new List<Filter>().GetEnumerator());

            // Act
            FilterInfo filterInfo = new FilterInfo(filtersMock.Object);

            // Assert
            filtersMock.Verify(f => f.GetEnumerator(), Times.Once());
        }

        [Fact]
        public void ActionFilters_ReturnsAllActionFilters_WhenOverrideScopeIsFirst()
        {
            // Arrange
            IActionFilter expectedFirstFilter = CreateDummyActionFilter();
            Filter firstFilter = CreateFilter(expectedFirstFilter, FilterScope.First);
            IActionFilter expectedGlobalFilter = CreateDummyActionFilter();
            Filter globalFilter = CreateFilter(expectedGlobalFilter, FilterScope.Global);
            IActionFilter expectedControllerFilter = CreateDummyActionFilter();
            Filter controllerFilter = CreateFilter(expectedControllerFilter, FilterScope.Controller);
            IActionFilter expectedActionFilter = CreateDummyActionFilter();
            Filter actionFilter = CreateFilter(expectedActionFilter, FilterScope.Action);
            IActionFilter expectedLastFilter = CreateDummyActionFilter();
            Filter lastFilter = CreateFilter(expectedLastFilter, FilterScope.Last);
            Filter overrideFilter = CreateFilter(CreateOverride(typeof(IActionFilter)), FilterScope.First);
            IEnumerable<Filter> filters = new Filter[] { firstFilter, globalFilter, controllerFilter, actionFilter,
                lastFilter, overrideFilter };
            FilterInfo product = CreateProductUnderTest(filters);

            // Act
            IList<IActionFilter> actionFilters = product.ActionFilters;

            // Assert
            Assert.NotNull(actionFilters);
            Assert.Equal(5, actionFilters.Count);
            Assert.Same(expectedFirstFilter, actionFilters[0]);
            Assert.Same(expectedGlobalFilter, actionFilters[1]);
            Assert.Same(expectedControllerFilter, actionFilters[2]);
            Assert.Same(expectedActionFilter, actionFilters[3]);
            Assert.Same(expectedLastFilter, actionFilters[4]);
        }

        [Fact]
        public void ActionFilters_ReturnsGlobalAndBelowActionFilters_WhenOverrideScopeIsGlobal()
        {
            // Arrange
            Filter firstFilter = CreateFilter(CreateDummyActionFilter(), FilterScope.First);
            IActionFilter expectedGlobalFilter = CreateDummyActionFilter();
            Filter globalFilter = CreateFilter(expectedGlobalFilter, FilterScope.Global);
            IActionFilter expectedControllerFilter = CreateDummyActionFilter();
            Filter controllerFilter = CreateFilter(expectedControllerFilter, FilterScope.Controller);
            IActionFilter expectedActionFilter = CreateDummyActionFilter();
            Filter actionFilter = CreateFilter(expectedActionFilter, FilterScope.Action);
            IActionFilter expectedLastFilter = CreateDummyActionFilter();
            Filter lastFilter = CreateFilter(expectedLastFilter, FilterScope.Last);
            Filter overrideFilter = CreateFilter(CreateOverride(typeof(IActionFilter)), FilterScope.Global);
            IEnumerable<Filter> filters = new Filter[] { firstFilter, globalFilter, controllerFilter, actionFilter,
                lastFilter, overrideFilter };
            FilterInfo product = CreateProductUnderTest(filters);

            // Act
            IList<IActionFilter> actionFilters = product.ActionFilters;

            // Assert
            Assert.NotNull(actionFilters);
            Assert.Equal(4, actionFilters.Count);
            Assert.Same(expectedGlobalFilter, actionFilters[0]);
            Assert.Same(expectedControllerFilter, actionFilters[1]);
            Assert.Same(expectedActionFilter, actionFilters[2]);
            Assert.Same(expectedLastFilter, actionFilters[3]);
        }

        [Fact]
        public void ActionFilters_ReturnsControllerAndBelowActionFilters_WhenOverrideScopeIsController()
        {
            // Arrange
            Filter firstFilter = CreateFilter(CreateDummyActionFilter(), FilterScope.First);
            Filter globalFilter = CreateFilter(CreateDummyActionFilter(), FilterScope.Global);
            IActionFilter expectedControllerFilter = CreateDummyActionFilter();
            Filter controllerFilter = CreateFilter(expectedControllerFilter, FilterScope.Controller);
            IActionFilter expectedActionFilter = CreateDummyActionFilter();
            Filter actionFilter = CreateFilter(expectedActionFilter, FilterScope.Action);
            IActionFilter expectedLastFilter = CreateDummyActionFilter();
            Filter lastFilter = CreateFilter(expectedLastFilter, FilterScope.Last);
            Filter overrideFilter = CreateFilter(CreateOverride(typeof(IActionFilter)), FilterScope.Controller);
            IEnumerable<Filter> filters = new Filter[] { firstFilter, globalFilter, controllerFilter, actionFilter,
                lastFilter, overrideFilter };
            FilterInfo product = CreateProductUnderTest(filters);

            // Act
            IList<IActionFilter> actionFilters = product.ActionFilters;

            // Assert
            Assert.NotNull(actionFilters);
            Assert.Equal(3, actionFilters.Count);
            Assert.Same(expectedControllerFilter, actionFilters[0]);
            Assert.Same(expectedActionFilter, actionFilters[1]);
            Assert.Same(expectedLastFilter, actionFilters[2]);
        }

        
        public ITestFilter BuildNUnitFilter()
        {
            var filters = new List<ITestFilter>();

            AddFilters(filters, testNames, (s) => new FullNameFilter(s));
            AddFilters(filters, groupNames, (s) => new FullNameFilter(s) {IsRegex = true});
            AddFilters(filters, assemblyNames, (s) => new AssemblyNameFilter(s));
            AddFilters(filters, categoryNames, (s) => new CategoryFilterExtended(s) {IsRegex = true});

            if (synchronousOnly)
            {
                filters.Add(new SynchronousFilter());
            }

            return filters.Count == 0 ? TestFilter.Empty : new AndFilter(filters.ToArray());
        }

        private static void AddFilters(List<ITestFilter> filters, string[] values, Func<string, TestFilter> builder)
        {
            if (values == null || values.Length == 0)
            {
                return;
            }

            var inclusionFilters = values.Where(v => !v.StartsWith("!")).Select(v => builder(v) as ITestFilter).ToArray();
            var exclusionFilters = values.Where(v => v.StartsWith("!"))
                .Select(v => new NotFilter(builder(v.Substring(1))) as ITestFilter)
                .ToArray();
            if (inclusionFilters.Length > 0 && exclusionFilters.Length > 0)
            {
                filters.Add(new AndFilter(new OrFilter(inclusionFilters), new AndFilter(exclusionFilters)));
            }
            else if (inclusionFilters.Length > 0)
            {
                filters.Add(new OrFilter(inclusionFilters));
            }
            else // Only exclusionFilters
            {
                filters.Add(new AndFilter(exclusionFilters));
            }
        }

        
        public ITestFilter BuildNUnitFilter()
        {
            var filters = new List<ITestFilter>();

            AddFilters(filters, testNames, (s) => new FullNameFilter(s));
            AddFilters(filters, groupNames, (s) => new FullNameFilter(s) {IsRegex = true});
            AddFilters(filters, assemblyNames, (s) => new AssemblyNameFilter(s));
            AddFilters(filters, categoryNames, (s) => new CategoryFilterExtended(s) {IsRegex = true});

            if (synchronousOnly)
            {
                filters.Add(new SynchronousFilter());
            }

            return filters.Count == 0 ? TestFilter.Empty : new AndFilter(filters.ToArray());
        }

        private static void AddFilters(List<ITestFilter> filters, string[] values, Func<string, TestFilter> builder)
        {
            if (values == null || values.Length == 0)
            {
                return;
            }

            var inclusionFilters = values.Where(v => !v.StartsWith("!")).Select(v => builder(v) as ITestFilter).ToArray();
            var exclusionFilters = values.Where(v => v.StartsWith("!"))
                .Select(v => new NotFilter(builder(v.Substring(1))) as ITestFilter)
                .ToArray();
            if (inclusionFilters.Length > 0 && exclusionFilters.Length > 0)
            {
                filters.Add(new AndFilter(new OrFilter(inclusionFilters), new AndFilter(exclusionFilters)));
            }
            else if (inclusionFilters.Length > 0)
            {
                filters.Add(new OrFilter(inclusionFilters));
            }
            else // Only exclusionFilters
            {
                filters.Add(new AndFilter(exclusionFilters));
            }
        }

        
        public ITestFilter BuildNUnitFilter()
        {
            var filters = new List<ITestFilter>();

            AddFilters(filters, testNames, (s) => new FullNameFilter(s));
            AddFilters(filters, groupNames, (s) => new FullNameFilter(s) {IsRegex = true});
            AddFilters(filters, assemblyNames, (s) => new AssemblyNameFilter(s));
            AddFilters(filters, categoryNames, (s) => new CategoryFilterExtended(s) {IsRegex = true});

            if (synchronousOnly)
            {
                filters.Add(new SynchronousFilter());
            }

            return filters.Count == 0 ? TestFilter.Empty : new AndFilter(filters.ToArray());
        }

        private static void AddFilters(List<ITestFilter> filters, string[] values, Func<string, TestFilter> builder)
        {
            if (values == null || values.Length == 0)
            {
                return;
            }

            var inclusionFilters = values.Where(v => !v.StartsWith("!")).Select(v => builder(v) as ITestFilter).ToArray();
            var exclusionFilters = values.Where(v => v.StartsWith("!"))
                .Select(v => new NotFilter(builder(v.Substring(1))) as ITestFilter)
                .ToArray();
            if (inclusionFilters.Length > 0 && exclusionFilters.Length > 0)
            {
                filters.Add(new AndFilter(new OrFilter(inclusionFilters), new AndFilter(exclusionFilters)));
            }
            else if (inclusionFilters.Length > 0)
            {
                filters.Add(new OrFilter(inclusionFilters));
            }
            else // Only exclusionFilters
            {
                filters.Add(new AndFilter(exclusionFilters));
            }
        }

        
        public ITestFilter BuildNUnitFilter()
        {
            var filters = new List<ITestFilter>();

            AddFilters(filters, testNames, (s) => new FullNameFilter(s));
            AddFilters(filters, groupNames, (s) => new FullNameFilter(s) {IsRegex = true});
            AddFilters(filters, assemblyNames, (s) => new AssemblyNameFilter(s));
            AddFilters(filters, categoryNames, (s) => new CategoryFilterExtended(s) {IsRegex = true});

            if (synchronousOnly)
            {
                filters.Add(new SynchronousFilter());
            }

            return filters.Count == 0 ? TestFilter.Empty : new AndFilter(filters.ToArray());
        }

        private static void AddFilters(List<ITestFilter> filters, string[] values, Func<string, TestFilter> builder)
        {
            if (values == null || values.Length == 0)
            {
                return;
            }

            var inclusionFilters = values.Where(v => !v.StartsWith("!")).Select(v => builder(v) as ITestFilter).ToArray();
            var exclusionFilters = values.Where(v => v.StartsWith("!"))
                .Select(v => new NotFilter(builder(v.Substring(1))) as ITestFilter)
                .ToArray();
            if (inclusionFilters.Length > 0 && exclusionFilters.Length > 0)
            {
                filters.Add(new AndFilter(new OrFilter(inclusionFilters), new AndFilter(exclusionFilters)));
            }
            else if (inclusionFilters.Length > 0)
            {
                filters.Add(new OrFilter(inclusionFilters));
            }
            else // Only exclusionFilters
            {
                filters.Add(new AndFilter(exclusionFilters));
            }
        }

        
        public ITestFilter BuildNUnitFilter()
        {
            var filters = new List<ITestFilter>();

            AddFilters(filters, testNames, (s) => new FullNameFilter(s));
            AddFilters(filters, groupNames, (s) => new FullNameFilter(s) {IsRegex = true});
            AddFilters(filters, assemblyNames, (s) => new AssemblyNameFilter(s));
            AddFilters(filters, categoryNames, (s) => new CategoryFilterExtended(s) {IsRegex = true});

            if (synchronousOnly)
            {
                filters.Add(new SynchronousFilter());
            }

            return filters.Count == 0 ? TestFilter.Empty : new AndFilter(filters.ToArray());
        }

        private static void AddFilters(List<ITestFilter> filters, string[] values, Func<string, TestFilter> builder)
        {
            if (values == null || values.Length == 0)
            {
                return;
            }

            var inclusionFilters = values.Where(v => !v.StartsWith("!")).Select(v => builder(v) as ITestFilter).ToArray();
            var exclusionFilters = values.Where(v => v.StartsWith("!"))
                .Select(v => new NotFilter(builder(v.Substring(1))) as ITestFilter)
                .ToArray();
            if (inclusionFilters.Length > 0 && exclusionFilters.Length > 0)
            {
                filters.Add(new AndFilter(new OrFilter(inclusionFilters), new AndFilter(exclusionFilters)));
            }
            else if (inclusionFilters.Length > 0)
            {
                filters.Add(new OrFilter(inclusionFilters));
            }
            else // Only exclusionFilters
            {
                filters.Add(new AndFilter(exclusionFilters));
            }
        }

        
        public ITestFilter BuildNUnitFilter()
        {
            var filters = new List<ITestFilter>();

            AddFilters(filters, testNames, (s) => new FullNameFilter(s));
            AddFilters(filters, groupNames, (s) => new FullNameFilter(s) {IsRegex = true});
            AddFilters(filters, assemblyNames, (s) => new AssemblyNameFilter(s));
            AddFilters(filters, categoryNames, (s) => new CategoryFilterExtended(s) {IsRegex = true});

            if (synchronousOnly)
            {
                filters.Add(new SynchronousFilter());
            }

            return filters.Count == 0 ? TestFilter.Empty : new AndFilter(filters.ToArray());
        }

        private static void AddFilters(List<ITestFilter> filters, string[] values, Func<string, TestFilter> builder)
        {
            if (values == null || values.Length == 0)
            {
                return;
            }

            var inclusionFilters = values.Where(v => !v.StartsWith("!")).Select(v => builder(v) as ITestFilter).ToArray();
            var exclusionFilters = values.Where(v => v.StartsWith("!"))
                .Select(v => new NotFilter(builder(v.Substring(1))) as ITestFilter)
                .ToArray();
            if (inclusionFilters.Length > 0 && exclusionFilters.Length > 0)
            {
                filters.Add(new AndFilter(new OrFilter(inclusionFilters), new AndFilter(exclusionFilters)));
            }
            else if (inclusionFilters.Length > 0)
            {
                filters.Add(new OrFilter(inclusionFilters));
            }
            else // Only exclusionFilters
            {
                filters.Add(new AndFilter(exclusionFilters));
            }
        }

        
        public ITestFilter BuildNUnitFilter()
        {
            var filters = new List<ITestFilter>();

            AddFilters(filters, testNames, (s) => new FullNameFilter(s));
            AddFilters(filters, groupNames, (s) => new FullNameFilter(s) {IsRegex = true});
            AddFilters(filters, assemblyNames, (s) => new AssemblyNameFilter(s));
            AddFilters(filters, categoryNames, (s) => new CategoryFilterExtended(s) {IsRegex = true});

            if (synchronousOnly)
            {
                filters.Add(new SynchronousFilter());
            }

            return filters.Count == 0 ? TestFilter.Empty : new AndFilter(filters.ToArray());
        }

        private static void AddFilters(List<ITestFilter> filters, string[] values, Func<string, TestFilter> builder)
        {
            if (values == null || values.Length == 0)
            {
                return;
            }

            var inclusionFilters = values.Where(v => !v.StartsWith("!")).Select(v => builder(v) as ITestFilter).ToArray();
            var exclusionFilters = values.Where(v => v.StartsWith("!"))
                .Select(v => new NotFilter(builder(v.Substring(1))) as ITestFilter)
                .ToArray();
            if (inclusionFilters.Length > 0 && exclusionFilters.Length > 0)
            {
                filters.Add(new AndFilter(new OrFilter(inclusionFilters), new AndFilter(exclusionFilters)));
            }
            else if (inclusionFilters.Length > 0)
            {
                filters.Add(new OrFilter(inclusionFilters));
            }
            else // Only exclusionFilters
            {
                filters.Add(new AndFilter(exclusionFilters));
            }
        }

Suave.Filters : Object

Methods :

public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> path(String pathAfterDomain = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> pathCi(String pathAfterDomain = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> pathStarts(String pathAfterDomainSubstr = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> pathStartsCi(String pathAfterDomainSubstr = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> method(HttpMethod method = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> get_isSecure()
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> hasFlag(String flag = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> pathRegex(String pathAfterDomainRegex = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> host(String hostname = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> serverHost(String hostname = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> clientHost(String hostname = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> get_GET()
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> get_POST()
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> get_DELETE()
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> get_PUT()
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> get_HEAD()
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> get_CONNECT()
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> get_PATCH()
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> get_TRACE()
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> get_OPTIONS()
public static String logFormat(HttpContext ctx = )
public static Tuple<String, FSharpMap<String, Object>> logFormatStructured(HttpContext ctx = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> logWithLevel(LogLevel level = , Logger logger = , FSharpFunc<HttpContext, String> messageFun = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> logWithLevelStructured(LogLevel level = , Logger logger = , FSharpFunc<HttpContext, Tuple<String, FSharpMap<String, Object>>> messageFun = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> logStructured(Logger logger = , FSharpFunc<HttpContext, Tuple<String, FSharpMap<String, Object>>> messageFun = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> log(Logger logger = , FSharpFunc<HttpContext, String> messageFun = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> pathScan(PrintfFormat<a, b, c, d, t> pf = , FSharpFunc<t, FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>>> h = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> pathScanCi(PrintfFormat<a, b, c, d, t> format = , FSharpFunc<t, FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>>> handler = )
public static FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> timeoutWebPart(TimeSpan timeout = , FSharpFunc<HttpContext, FSharpAsync<FSharpOption<HttpContext>>> child = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

Other methods