当前位置: 首页>>代码示例>>C#>>正文


C# Filter.ExcludeByAttribute方法代码示例

本文整理汇总了C#中OpenCover.Framework.Filter.ExcludeByAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Filter.ExcludeByAttribute方法的具体用法?C# Filter.ExcludeByAttribute怎么用?C# Filter.ExcludeByAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenCover.Framework.Filter的用法示例。


在下文中一共展示了Filter.ExcludeByAttribute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Can_Identify_Excluded_Properties

        public void Can_Identify_Excluded_Properties()
        {
            var sourceAssembly = AssemblyDefinition.ReadAssembly(typeof(Samples.Concrete).Assembly.Location);

            var type = sourceAssembly.MainModule.Types.First(x => x.FullName == typeof(Samples.Concrete).FullName);

            var filter = new Filter();
            filter.AddAttributeExclusionFilters(new[] { "*ExcludeMethodAttribute" });

            foreach (var propertyDefinition in type.Properties)
            {
                Assert.True(filter.ExcludeByAttribute(propertyDefinition));
            }
        }
开发者ID:alistair,项目名称:opencover,代码行数:14,代码来源:FilterTests.cs

示例2: Entity_Is_Not_Excluded_If_No_Filters_Set

        public void Entity_Is_Not_Excluded_If_No_Filters_Set()
        {
            var filter = new Filter();
            var entity = new Mock<ICustomAttributeProvider>();

            Assert.IsFalse(filter.ExcludeByAttribute(entity.Object));
        }
开发者ID:alistair,项目名称:opencover,代码行数:7,代码来源:FilterTests.cs

示例3: Can_Identify_Excluded_Methods

        public void Can_Identify_Excluded_Methods()
        {
            var sourceAssembly = AssemblyDefinition.ReadAssembly(typeof(Samples.Concrete).Assembly.Location);

            var type = sourceAssembly.MainModule.Types.First(x => x.FullName == typeof (Samples.Concrete).FullName);

            var filter = new Filter();
            filter.AddAttributeExclusionFilters(new[] { "*ExcludeMethodAttribute" });

            foreach (var methodDefinition in type.Methods)
            {
                if (methodDefinition.IsSetter || methodDefinition.IsGetter) continue;
                Assert.True(filter.ExcludeByAttribute(methodDefinition));                
            }

        }
开发者ID:alistair,项目名称:opencover,代码行数:16,代码来源:FilterTests.cs

示例4: Can_Identify_Included_Anonymous_Issue99

        public void Can_Identify_Included_Anonymous_Issue99()
        {
            var sourceAssembly = AssemblyDefinition.ReadAssembly(typeof(Samples.Anonymous).Assembly.Location);

            var type = sourceAssembly.MainModule.Types.First(x => x.FullName == typeof(Samples.Anonymous).FullName);

            var filter = new Filter();
            filter.AddAttributeExclusionFilters(new[] { "*ExcludeMethodAttribute" });

            foreach (var methodDefinition in type.Methods.Where(x => x.Name.Contains("INCLUDE")))
            {
                if (methodDefinition.IsSetter || methodDefinition.IsGetter || methodDefinition.IsConstructor) continue;
                Assert.False(filter.ExcludeByAttribute(methodDefinition), "failed to include {0}", methodDefinition.Name);
            }
        }
开发者ID:nagyist,项目名称:sawilde-opencover,代码行数:15,代码来源:FilterTests.cs

示例5: Handles_Issue117

        public void Handles_Issue117()
        {
            var filter = new Filter();
            filter.AddAttributeExclusionFilters(new[] { "*ExcludeMethodAttribute" });

            var mockDefinition = new Mock<IMemberDefinition>();

            mockDefinition.SetupGet(x => x.HasCustomAttributes).Returns(true);
            mockDefinition.SetupGet(x => x.CustomAttributes).Returns(new Collection<CustomAttribute>());
            mockDefinition.SetupGet(x => x.Name).Returns("<>f_ddd");
            mockDefinition.SetupGet(x => x.DeclaringType).Returns(new TypeDefinition("","f_ddd", TypeAttributes.Public));

            Assert.DoesNotThrow(() => filter.ExcludeByAttribute(mockDefinition.Object));
        }
开发者ID:nagyist,项目名称:sawilde-opencover,代码行数:14,代码来源:FilterTests.cs

示例6: Entity_Is_Not_Excluded_If_No_Filters_Set

        public void Entity_Is_Not_Excluded_If_No_Filters_Set()
        {
            var filter = new Filter();
            var entity = new Mock<IMemberDefinition>();

            Assert.IsFalse(filter.ExcludeByAttribute(entity.Object));
        }
开发者ID:nagyist,项目名称:sawilde-opencover,代码行数:7,代码来源:FilterTests.cs

示例7: Can_Identify_Excluded_Methods_UsingRegularExpressions

        public void Can_Identify_Excluded_Methods_UsingRegularExpressions()
        {
            // arrange
            var filter = new Filter(true);
            filter.AddAttributeExclusionFilters(new[] { ".*ExcludeMethodAttribute" });

            // act
            var sourceAssembly = AssemblyDefinition.ReadAssembly(typeof(Samples.Concrete).Assembly.Location);
            var type = sourceAssembly.MainModule.Types.First(x => x.FullName == typeof(Samples.Concrete).FullName);

            // assert
            foreach (var methodDefinition in type.Methods.Where(methodDefinition => !methodDefinition.IsSetter && !methodDefinition.IsGetter))
            {
                Assert.True(filter.ExcludeByAttribute(methodDefinition));
            }
        }
开发者ID:AtwooTM,项目名称:opencover,代码行数:16,代码来源:FilterTests.cs

示例8: Can_Identify_Excluded_Types

        public void Can_Identify_Excluded_Types(string typeName)
        {
            // arrange
            var sourceAssembly = AssemblyDefinition.ReadAssembly(typeof(Samples.Concrete).Assembly.Location);

            // act
            var filter = new Filter(false);
            var allTypes = AllTypes(sourceAssembly.MainModule);
            var typeDefinition = allTypes.First(x => x.Name == typeName);
            
            Assert.False(filter.ExcludeByAttribute(typeDefinition));

            // assert
            filter.AddAttributeExclusionFilters(new[] { "*ExcludeClassAttribute" });
            foreach (var methodDefinition in typeDefinition.Methods)
            {
                if (methodDefinition.IsSetter || methodDefinition.IsGetter) continue;
                Assert.True(filter.ExcludeByAttribute(methodDefinition));
            }
            Assert.True(filter.ExcludeByAttribute(typeDefinition));
            foreach (var nestedType in AllNestedTypes(typeDefinition))
            {
                Assert.True(filter.ExcludeByAttribute(nestedType));
            }
        }
开发者ID:AtwooTM,项目名称:opencover,代码行数:25,代码来源:FilterTests.cs

示例9: Can_Identify_Excluded_Assemblies

        public void Can_Identify_Excluded_Assemblies()
        {
            // arrange
            var sourceAssembly = AssemblyDefinition.ReadAssembly(typeof(Samples.Concrete).Assembly.Location);
           
            // act
            var filter = new Filter(false);
            Assert.False(filter.ExcludeByAttribute(sourceAssembly));

            // assert
            filter.AddAttributeExclusionFilters(new[] { "*ExcludeAssemblyAttribute" });
            Assert.True(filter.ExcludeByAttribute(sourceAssembly));
        }
开发者ID:AtwooTM,项目名称:opencover,代码行数:13,代码来源:FilterTests.cs

示例10: Can_Identify_Excluded_Types

        public void Can_Identify_Excluded_Types()
        {
            // arrange
            var sourceAssembly = AssemblyDefinition.ReadAssembly(typeof(Samples.Concrete).Assembly.Location);

            // act
            var filter = new Filter();
            foreach (var typeDefinition in sourceAssembly.MainModule.Types.Where(x => x.Name == "Concrete"))
            {
                Assert.False(filter.ExcludeByAttribute(typeDefinition));
            }

            // assert
            filter.AddAttributeExclusionFilters(new[] { "*ExcludeClassAttribute" });
            foreach (var typeDefinition in sourceAssembly.MainModule.Types.Where(x => x.Name == "Concrete"))
            {
                Assert.True(filter.ExcludeByAttribute(typeDefinition));
            }
        }
开发者ID:jayrowe,项目名称:opencover,代码行数:19,代码来源:FilterTests.cs


注:本文中的OpenCover.Framework.Filter.ExcludeByAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。