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


C# IAttributeInfo类代码示例

本文整理汇总了C#中IAttributeInfo的典型用法代码示例。如果您正苦于以下问题:C# IAttributeInfo类的具体用法?C# IAttributeInfo怎么用?C# IAttributeInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: KuduXunitTheoryTestCase

 public KuduXunitTheoryTestCase(IMessageSink diagnosticMessageSink,
                                TestMethodDisplay defaultMethodDisplay,
                                ITestMethod testMethod,
                                IAttributeInfo testAttribute)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod)
 {
 }
开发者ID:NorimaConsulting,项目名称:kudu,代码行数:7,代码来源:KuduXunitTheoryTestCase.cs

示例2: GetTestFrameworkType

 public Type GetTestFrameworkType(IAttributeInfo attribute)
 {
     if (BenchmarkConfiguration.RunningAsPerfTest)
         return typeof(BenchmarkTestFramework);
     else
         return typeof(XunitTestFramework);
 }
开发者ID:visia,项目名称:xunit-performance,代码行数:7,代码来源:BenchmarkTestFrameworkTypeDiscoverer.cs

示例3:

 public IEnumerable<IXunitTestCase> Discover
   ( ITestFrameworkDiscoveryOptions discoveryOptions
   , ITestMethod testMethod
   , IAttributeInfo factAttribute
   )
 {
     var inv = InvariantTestCase.InvariantFromMethod(testMethod);
     return
         inv == null
         ? new[]
           { new InvariantTestCase
               ( MessageSink
               , TestMethodDisplay.Method
               , testMethod
               , null
               )
           }
         : inv.AsSeq().Select
             ( i =>
                   new InvariantTestCase
                     ( MessageSink
                     , TestMethodDisplay.Method
                     , testMethod
                     , i
                     )
             );
 }
开发者ID:sharper-library,项目名称:Sharper.C.Testing,代码行数:27,代码来源:InvariantDiscoverer.cs

示例4: Discover

        public virtual IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
        {
            var variations = testMethod.Method
                .GetCustomAttributes(typeof(BenchmarkVariationAttribute))
                .ToDictionary(
                    a => a.GetNamedArgument<string>(nameof(BenchmarkVariationAttribute.VariationName)),
                    a => a.GetNamedArgument<object[]>(nameof(BenchmarkVariationAttribute.Data)));

            if (!variations.Any())
            {
                variations.Add("Default", new object[0]);
            }

            var tests = new List<IXunitTestCase>();
            foreach (var variation in variations)
            {
                tests.Add(new BenchmarkTestCase(
                    factAttribute.GetNamedArgument<int>(nameof(BenchmarkAttribute.Iterations)),
                    factAttribute.GetNamedArgument<int>(nameof(BenchmarkAttribute.WarmupIterations)),
                    variation.Key,
                    _diagnosticMessageSink,
                    testMethod,
                    variation.Value));
            }

            return tests;
        }
开发者ID:tuespetre,项目名称:mvc-sandbox,代码行数:27,代码来源:BenchmarkTestDiscoverer.cs

示例5: CulturedXunitTestCase

        public CulturedXunitTestCase(ITestCollection testCollection, IAssemblyInfo assembly, ITypeInfo type, IMethodInfo method, IAttributeInfo factAttribute, string culture)
            : base(testCollection, assembly, type, method, factAttribute)
        {
            this.culture = culture;

            Traits.Add("Culture", culture);
        }
开发者ID:kerryjiang,项目名称:xunit,代码行数:7,代码来源:CulturedXunitTestCase.cs

示例6: Discover

        public IEnumerable<IXunitTestCase> Discover(
            ITestFrameworkDiscoveryOptions discoveryOptions,
            ITestMethod testMethod,
            IAttributeInfo factAttribute)
        {
            var skipReason = EvaluateSkipConditions(testMethod);

            var isTheory = false;
            IXunitTestCaseDiscoverer innerDiscoverer;
            if (testMethod.Method.GetCustomAttributes(typeof(TheoryAttribute)).Any())
            {
                isTheory = true;
                innerDiscoverer = new TheoryDiscoverer(_diagnosticMessageSink);
            }
            else
            {
                innerDiscoverer = new FactDiscoverer(_diagnosticMessageSink);
            }

            var testCases = innerDiscoverer
                .Discover(discoveryOptions, testMethod, factAttribute)
                .Select(testCase => new SkipReasonTestCase(isTheory, skipReason, testCase));

            return testCases;
        }
开发者ID:krwq,项目名称:Testing,代码行数:25,代码来源:ConditionalAttributeDiscoverer.cs

示例7: UnresolvedCustomAttributeData

        public UnresolvedCustomAttributeData(IAttributeInfo adapter)
        {
            if (adapter == null)
                throw new ArgumentNullException("adapter");

            this.adapter = adapter;
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:7,代码来源:UnresolvedCustomAttributeData.cs

示例8: Discover

        public override IEnumerable<IXunitTestCase> Discover(
            ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
        {
            MethodInfo testMethodInfo = testMethod.Method.ToRuntimeMethod();

            string conditionMemberName = factAttribute.GetConstructorArguments().FirstOrDefault() as string;
            MethodInfo conditionMethodInfo;
            if (conditionMemberName == null ||
                (conditionMethodInfo = LookupConditionalMethod(testMethodInfo.DeclaringType, conditionMemberName)) == null)
            {
                return new[] {
                    new ExecutionErrorTestCase(
                        _diagnosticMessageSink,
                        discoveryOptions.MethodDisplayOrDefault(),
                        testMethod,
                        GetFailedLookupString(conditionMemberName))
                };
            }

            IEnumerable<IXunitTestCase> testCases = base.Discover(discoveryOptions, testMethod, factAttribute);
            if ((bool)conditionMethodInfo.Invoke(null, null))
            {
                return testCases;
            }
            else
            {
                string skippedReason = "\"" + conditionMemberName + "\" returned false.";
                return testCases.Select(tc => new SkippedTestCase(tc, skippedReason));
            }
        }
开发者ID:jango2015,项目名称:buildtools,代码行数:30,代码来源:ConditionalFactDiscoverer.cs

示例9: Initialize

        void Initialize(ITestCollection testCollection, IAssemblyInfo assembly, ITypeInfo type, IMethodInfo method, IAttributeInfo factAttribute, object[] arguments)
        {
            string displayNameBase = factAttribute.GetNamedArgument<string>("DisplayName") ?? type.Name + "." + method.Name;
            ITypeInfo[] resolvedTypes = null;

            if (arguments != null && method.IsGenericMethodDefinition)
            {
                resolvedTypes = ResolveGenericTypes(method, arguments);
                method = method.MakeGenericMethod(resolvedTypes);
            }

            Assembly = assembly;
            Class = type;
            Method = method;
            Arguments = arguments;
            DisplayName = GetDisplayNameWithArguments(displayNameBase, arguments, resolvedTypes);
            SkipReason = factAttribute.GetNamedArgument<string>("Skip");
            Traits = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
            TestCollection = testCollection;

            foreach (IAttributeInfo traitAttribute in Method.GetCustomAttributes(typeof(TraitAttribute))
                                                            .Concat(Class.GetCustomAttributes(typeof(TraitAttribute))))
            {
                var ctorArgs = traitAttribute.GetConstructorArguments().ToList();
                Traits.Add((string)ctorArgs[0], (string)ctorArgs[1]);
            }

            uniqueID = new Lazy<string>(GetUniqueID, true);
        }
开发者ID:valmaev,项目名称:xunit,代码行数:29,代码来源:XunitTestCase.cs

示例10: GetData

        /// <inheritdoc/>
        public virtual IEnumerable<object[]> GetData(IAttributeInfo dataAttribute, IMethodInfo testMethod)
        {
            var reflectionDataAttribute = dataAttribute as IReflectionAttributeInfo;
            var reflectionTestMethod = testMethod as IReflectionMethodInfo;

            if (reflectionDataAttribute != null && reflectionTestMethod != null)
            {
                var attribute = (DataAttribute)reflectionDataAttribute.Attribute;
                try
                {
                    return attribute.GetData(reflectionTestMethod.MethodInfo);
                }
                catch (ArgumentException)
                {
                    // If we couldn't find the data on the base type, check if it is in current type.
                    // This allows base classes to specify data that exists on a sub type, but not on the base type.
                    var memberDataAttribute = attribute as MemberDataAttribute;
                    var reflectionTestMethodType = reflectionTestMethod.Type as IReflectionTypeInfo;
                    if (memberDataAttribute != null && memberDataAttribute.MemberType == null)
                    {
                        memberDataAttribute.MemberType = reflectionTestMethodType.Type;
                    }
                    return attribute.GetData(reflectionTestMethod.MethodInfo);
                }
            }

            return null;
        }
开发者ID:commonsensesoftware,项目名称:xunit,代码行数:29,代码来源:DataDiscoverer.cs

示例11: Discover

		public IEnumerable<IXunitTestCase> Discover (ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
		{
			var defaultMethodDisplay = discoveryOptions.MethodDisplayOrDefault ();
			if (testMethod.Method.GetParameters ().Any ()) {
				return new IXunitTestCase[] {
					new ExecutionErrorTestCase (messageSink, defaultMethodDisplay, testMethod,  "[VsixFact] methods are not allowed to have parameters.")
				};
			} else {
				var vsVersions = VsVersions.GetFinalVersions(testMethod.GetComputedProperty<string[]>(factAttribute, SpecialNames.VsixAttribute.VisualStudioVersions));
				// Process VS-specific traits.
				var suffix = testMethod.GetComputedArgument<string>(factAttribute, SpecialNames.VsixAttribute.RootSuffix) ?? "Exp";
				var newInstance = testMethod.GetComputedArgument<bool?>(factAttribute, SpecialNames.VsixAttribute.NewIdeInstance);
				var timeout = testMethod.GetComputedArgument<int?>(factAttribute, SpecialNames.VsixAttribute.TimeoutSeconds).GetValueOrDefault(XunitExtensions.DefaultTimeout);

				var testCases = new List<IXunitTestCase>();

				// Add invalid VS versions.
				testCases.AddRange (vsVersions
					.Where (v => !VsVersions.InstalledVersions.Contains (v))
					.Select (v => new ExecutionErrorTestCase (messageSink, defaultMethodDisplay, testMethod,
						string.Format ("Cannot execute test for specified {0}={1} because there is no VSSDK installed for that version.", SpecialNames.VsixAttribute.VisualStudioVersions, v))));

				testCases.AddRange (vsVersions
					.Where (v => VsVersions.InstalledVersions.Contains (v))
					.Select (v => new VsixTestCase (messageSink, defaultMethodDisplay, testMethod, v, suffix, newInstance, timeout)));

				return testCases;
			}
		}
开发者ID:victorgarciaaprea,项目名称:xunit.vsix,代码行数:29,代码来源:VsixFactDiscoverer.cs

示例12: GetTraits

 /// <summary>
 /// Gets the trait values from the Category attribute.
 /// </summary>
 /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
 /// <returns>The trait values.</returns>
 public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
 {
     TargetFrameworkMonikers platform = (TargetFrameworkMonikers)traitAttribute.GetConstructorArguments().First();
     if (platform.HasFlag(TargetFrameworkMonikers.Net45))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet45Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net451))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet451Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net452))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet452Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net46))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet46Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net461))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet461Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net462))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet462Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net463))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet463Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Netcore50))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcore50Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Netcore50aot))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcore50aotTest);
     if (platform.HasFlag(TargetFrameworkMonikers.Netcoreapp1_0))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcoreapp1_0Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Netcoreapp1_1))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcoreapp1_1Test);
 }
开发者ID:roncain,项目名称:buildtools,代码行数:31,代码来源:SkipOnTargetFrameworkDiscoverer.cs

示例13: Discover

 public override IEnumerable<IXunitTestCase> Discover(
     ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
 {
     string[] conditionMemberNames = factAttribute.GetConstructorArguments().FirstOrDefault() as string[];
     IEnumerable<IXunitTestCase> testCases = base.Discover(discoveryOptions, testMethod, factAttribute);
     return ConditionalTestDiscoverer.Discover(discoveryOptions, _diagnosticMessageSink, testMethod, testCases, conditionMemberNames);
 }
开发者ID:dsgouda,项目名称:buildtools,代码行数:7,代码来源:ConditionalFactDiscoverer.cs

示例14: Discover

 public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
 {
     var defaultMethodDisplay = discoveryOptions.MethodDisplayOrDefault();
     return factAttribute.GetNamedArgument<string>("Skip") != null
         ? new[] { new XunitTestCase(_diagnosticMessageSink, defaultMethodDisplay, testMethod) }
         : new XunitTestCase[] { new ScenarioTestCase(_diagnosticMessageSink, defaultMethodDisplay, testMethod) };
 }
开发者ID:surgeforward,项目名称:LightBDD,代码行数:7,代码来源:ScenarioTestCaseDiscoverer.cs

示例15: Initialize

        void Initialize(ITestCollection testCollection, IAssemblyInfo assembly, ITypeInfo type, IMethodInfo method, IAttributeInfo factAttribute, object[] arguments)
        {
            string displayNameBase = factAttribute.GetNamedArgument<string>("DisplayName") ?? type.Name + "." + method.Name;
            ITypeInfo[] resolvedTypes = null;

            if (arguments != null && method.IsGenericMethodDefinition)
            {
                resolvedTypes = ResolveGenericTypes(method, arguments);
                method = method.MakeGenericMethod(resolvedTypes);
            }

            Assembly = assembly;
            Class = type;
            Method = method;
            Arguments = arguments;
            DisplayName = GetDisplayNameWithArguments(displayNameBase, arguments, resolvedTypes);
            SkipReason = factAttribute.GetNamedArgument<string>("Skip");
            Traits = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
            TestCollection = testCollection;

            foreach (var traitAttribute in Method.GetCustomAttributes(typeof(ITraitAttribute))
                                                 .Concat(Class.GetCustomAttributes(typeof(ITraitAttribute))))
            {
                var discovererAttribute = traitAttribute.GetCustomAttributes(typeof(TraitDiscovererAttribute)).First();
                var discoverer = ExtensibilityPointFactory.GetTraitDiscoverer(discovererAttribute);
                if (discoverer != null)
                    foreach (var keyValuePair in discoverer.GetTraits(traitAttribute))
                        Traits.Add(keyValuePair.Key, keyValuePair.Value);
            }

            uniqueID = new Lazy<string>(GetUniqueID, true);
        }
开发者ID:vkomarovsky-sugarcrm,项目名称:xunit,代码行数:32,代码来源:XunitTestCase.cs


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