本文整理汇总了C#中IMethodInfo.HasAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodInfo.HasAttribute方法的具体用法?C# IMethodInfo.HasAttribute怎么用?C# IMethodInfo.HasAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethodInfo
的用法示例。
在下文中一共展示了IMethodInfo.HasAttribute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnumerateTestCommands
public IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo testMethod) {
foreach (var testCommand in _classCommand.EnumerateTestCommands(testMethod)) {
if (testMethod.HasAttribute(typeof(FullTrustAttribute))
|| testCommand is PartialTrustCommand) {
yield return testCommand;
continue;
}
yield return new PartialTrustCommand(testCommand);
}
}
示例2: ValidateRequirements
private bool ValidateRequirements(IMethodInfo method)
{
if (method.HasAttribute(typeof(RuntimeTestAttribute)))
{
RuntimeTestAttribute attr = method.GetCustomAttributes(typeof(RuntimeTestAttribute)).First().GetInstance<RuntimeTestAttribute>();
if (!(RuntimeTestAttribute.RuntimeTestsEnabled || Debugger.IsAttached))
{
this.Skip = String.Format("Runtime tests are not enabled on this test environment. To enable runtime tests set the environment variable '{0}'=true or run the tests under a debugger.", RuntimeTestAttribute.RuntimeTestsEnabledEnvironmentVariable);
return false;
}
else if (!(attr.NonPrivileged || UacUtilities.IsProcessElevated))
{
this.Skip = String.Format("The runtime test '{0}' requires that the test process be elevated.", method.Name);
return false;
}
}
else if (method.HasAttribute(typeof(Is64BitSpecificTestAttribute)) && !Is64BitSpecificTestAttribute.Is64BitOperatingSystem)
{
this.Skip = "64-bit specific tests are not enabled on 32-bit machines.";
return false;
}
return true;
}
示例3: IsTest
public static bool IsTest(IMethodInfo method)
{
return !method.IsAbstract &&
method.HasAttribute(typeof(FactAttribute));
}
示例4: HasTraits
public static bool HasTraits(IMethodInfo method)
{
return method.HasAttribute(typeof(TraitAttribute))
|| method.Class.HasAttribute(typeof(TraitAttribute));
}
示例5: IsSpec
private static bool IsSpec(IMethodInfo testMethod)
{
return testMethod.HasAttribute(typeof(SpecForAttribute));
}
示例6: IsVerifyMethod
private static bool IsVerifyMethod(IMethodInfo testMethod)
{
return testMethod.HasAttribute(typeof(FactAttribute));
}
示例7: IsTestMethod
public bool IsTestMethod(IMethodInfo testMethod)
{
return testMethod.HasAttribute(typeof(FactAttribute));
}
示例8: IsTestMethod
public bool IsTestMethod(IMethodInfo testMethod)
{
// The ObservationAttribute is really not even required; we could just say any void-returning public
// method is a test method (or you could say it has to start with "should").
return testMethod.HasAttribute(typeof(ObservationAttribute));
}
示例9: IsTest
/// <summary>
/// Determines whether a method is a test method. A test method must be decorated
/// with the <see cref="FactAttribute"/> (or derived class) and must not be abstract.
/// </summary>
/// <param name="method">The method to be inspected</param>
/// <returns>True if the method is a test method; false, otherwise</returns>
public static bool IsTest(IMethodInfo method)
{
Guard.ArgumentNotNull("method", method);
return !method.IsAbstract &&
method.HasAttribute(typeof(FactAttribute));
}
示例10: HasTraits
/// <summary>
/// Determines whether a test method has traits.
/// </summary>
/// <param name="method">The method to be inspected</param>
/// <returns>True if the method has traits; false, otherwise</returns>
public static bool HasTraits(IMethodInfo method)
{
Guard.ArgumentNotNull("method", method);
return method.HasAttribute(typeof(TraitAttribute))
|| method.Class.HasAttribute(typeof(TraitAttribute));
}