本文整理汇总了C#中OpenCover.Framework.Filter.AddFilter方法的典型用法代码示例。如果您正苦于以下问题:C# Filter.AddFilter方法的具体用法?C# Filter.AddFilter怎么用?C# Filter.AddFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCover.Framework.Filter
的用法示例。
在下文中一共展示了Filter.AddFilter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddFilter_ThrowsException_WhenInvalid_AssemblyClassPair
public void AddFilter_ThrowsException_WhenInvalid_AssemblyClassPair(
[ValueSource("_invalidAssemblyClassPairs")]string assemblyClassPair)
{
// arrange
var filter = new Filter();
// act/assert
Assert.Catch<InvalidOperationException>(() => filter.AddFilter(assemblyClassPair),
"'{0}' should be invalid", assemblyClassPair);
}
示例2: BuildFilter
private static IFilter BuildFilter(CommandLineParser parser)
{
var filter = new Filter();
// apply filters
if (!parser.NoDefaultFilters)
{
filter.AddFilter("-[mscorlib]*");
filter.AddFilter("-[mscorlib.*]*");
filter.AddFilter("-[System]*");
filter.AddFilter("-[System.*]*");
filter.AddFilter("-[Microsoft.VisualBasic]*");
}
if (parser.Filters.Count == 0)
{
filter.AddFilter("+[*]*");
}
else
{
parser.Filters.ForEach(filter.AddFilter);
}
filter.AddAttributeExclusionFilters(parser.AttributeExclusionFilters.ToArray());
filter.AddFileExclusionFilters(parser.FileExclusionFilters.ToArray());
filter.AddTestFileFilters(parser.TestFilters.ToArray());
return filter;
}
示例3: BuildFilter
private static Filter BuildFilter(CommandLineParser parser)
{
var filter = new Filter();
// apply filters
if (!parser.NoDefaultFilters)
{
filter.AddFilter("-[mscorlib]*");
filter.AddFilter("-[System]*");
filter.AddFilter("-[System.*]*");
filter.AddFilter("-[Microsoft.VisualBasic]*");
}
if (parser.Filters.Count == 0)
{
filter.AddFilter("+[*]*");
}
else
{
parser.Filters.ForEach(filter.AddFilter);
}
return filter;
}
示例4: BuildFilter
private static IFilter BuildFilter(CommandLineParser parser)
{
var filter = new Filter();
// apply filters
if (!parser.NoDefaultFilters)
{
filter.AddFilter("-[mscorlib]*");
filter.AddFilter("-[mscorlib.*]*");
filter.AddFilter("-[System]*");
filter.AddFilter("-[System.*]*");
filter.AddFilter("-[Microsoft.VisualBasic]*");
}
if (parser.Filters.Count == 0 && string.IsNullOrEmpty(parser.FilterFile))
{
filter.AddFilter("+[*]*");
}
else
{
if (!string.IsNullOrEmpty(parser.FilterFile))
{
if (!File.Exists(parser.FilterFile))
System.Console.WriteLine("FilterFile '{0}' cannot be found - have you specified your arguments correctly?", parser.FilterFile);
else
{
var filters = File.ReadAllLines(parser.FilterFile);
filters.ToList().ForEach(filter.AddFilter);
}
}
if (parser.Filters.Count > 0)
{
parser.Filters.ForEach(filter.AddFilter);
}
}
filter.AddAttributeExclusionFilters(parser.AttributeExclusionFilters.ToArray());
filter.AddFileExclusionFilters(parser.FileExclusionFilters.ToArray());
filter.AddTestFileFilters(parser.TestFilters.ToArray());
return filter;
}
示例5: AddFilter_Adds_ValidAssemblyClassPair
public void AddFilter_Adds_ValidAssemblyClassPair(
[ValueSource("_assemblyClassPairs")]AssemblyClassData assemblyClassPair)
{
// arrange
var filter = new Filter();
// act
filter.AddFilter(assemblyClassPair.AssemblyClass);
// assert
Assert.AreEqual(1, assemblyClassPair.FilterTypeResult == FilterType.Inclusion ?
filter.InclusionFilter.Count : filter.ExclusionFilter.Count);
Assert.AreEqual(assemblyClassPair.AssemblyResult, assemblyClassPair.FilterTypeResult == FilterType.Inclusion ?
filter.InclusionFilter[0].Key : filter.ExclusionFilter[0].Key);
Assert.AreEqual(assemblyClassPair.ClassResult, assemblyClassPair.FilterTypeResult == FilterType.Inclusion ?
filter.InclusionFilter[0].Value : filter.ExclusionFilter[0].Value);
}
示例6: BuildFilter
/// <summary>
/// Create a filter entity from parser parameters
/// </summary>
/// <param name="parser"></param>
/// <returns></returns>
public static IFilter BuildFilter(CommandLineParser parser)
{
var filter = new Filter(parser.RegExFilters);
// apply filters
if (!parser.NoDefaultFilters)
{
if (parser.RegExFilters)
{
filter.AddFilter(@"-[(mscorlib)](.*)");
filter.AddFilter(@"-[(mscorlib\..*)](.*)");
filter.AddFilter(@"-[(System)](.*)");
filter.AddFilter(@"-[(System\..*)](.*)");
filter.AddFilter(@"-[(Microsoft.VisualBasic)](.*)");
}
else
{
filter.AddFilter("-[mscorlib]*");
filter.AddFilter("-[mscorlib.*]*");
filter.AddFilter("-[System]*");
filter.AddFilter("-[System.*]*");
filter.AddFilter("-[Microsoft.VisualBasic]*");
}
}
if (parser.Filters.Count > 0)
{
parser.Filters.ForEach(filter.AddFilter);
}
filter.AddAttributeExclusionFilters(parser.AttributeExclusionFilters.ToArray());
filter.AddFileExclusionFilters(parser.FileExclusionFilters.ToArray());
filter.AddTestFileFilters(parser.TestFilters.ToArray());
foreach (var excludeDir in parser.ExcludeDirs)
{
filter.AddExcludedFolder(excludeDir);
}
return filter;
}
示例7: CanHandle_AssemblyClassFilters_ExpressedAs_RegularExpressions
public void CanHandle_AssemblyClassFilters_ExpressedAs_RegularExpressions(string namespaceClass, bool canInstrument)
{
// arrange
var filter = new Filter(true);
filter.AddFilter(@"+[(A1\.B[23])]([CD]1.*)");
// act
// assert
Assert.AreEqual(canInstrument, filter.InstrumentClass("A1.B2", namespaceClass));
}
示例8: CanHandle_AssemblyFilters_ExpressedAs_RegularExpressions
public void CanHandle_AssemblyFilters_ExpressedAs_RegularExpressions(string assembly, bool canUse)
{
// arrange
var filter = new Filter(true);
filter.AddFilter(@"+[(A1\.B[23])]([CD]1.*)");
// act
// assert
Assert.AreEqual(canUse, filter.UseAssembly("processName", assembly));
}
示例9: AddFilter_Adds_ValidAssemblyClassPair
public void AddFilter_Adds_ValidAssemblyClassPair(
[ValueSource("_filterExpressions")]FilterData assemblyClassPair)
{
// arrange
var filter = new Filter(false);
// act
filter.AddFilter(assemblyClassPair.FilterExpression);
// assert
Assert.AreEqual(1, assemblyClassPair.FilterTypeResult == FilterType.Inclusion ?
filter.InclusionFilters.Count : filter.ExclusionFilters.Count);
Assert.AreEqual(assemblyClassPair.ProcessResult,
assemblyClassPair.FilterTypeResult == FilterType.Inclusion ?
filter.InclusionFilters[0].ProcessName
: filter.ExclusionFilters[0].ProcessName);
Assert.AreEqual(assemblyClassPair.AssemblyResult,
assemblyClassPair.FilterTypeResult == FilterType.Inclusion ?
filter.InclusionFilters[0].AssemblyName
: filter.ExclusionFilters[0].AssemblyName);
Assert.AreEqual(assemblyClassPair.ClassResult,
assemblyClassPair.FilterTypeResult == FilterType.Inclusion ?
filter.InclusionFilters[0].ClassName
: filter.ExclusionFilters[0].ClassName);
}
示例10: AddFilter_ThrowsException_WhenInvalid_AssemblyClassPair
public void AddFilter_ThrowsException_WhenInvalid_AssemblyClassPair(
[ValueSource("_invalidFilterExpressions")]string assemblyClassPair)
{
// arrange
var filter = new Filter(false);
// act/assert
Assert.Catch<ExitApplicationWithoutReportingException>(() => filter.AddFilter(assemblyClassPair),
"'{0}' should be invalid", assemblyClassPair);
}