本文整理汇总了C#中ITestFrameworkDiscoveryOptions.MethodDisplayOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# ITestFrameworkDiscoveryOptions.MethodDisplayOrDefault方法的具体用法?C# ITestFrameworkDiscoveryOptions.MethodDisplayOrDefault怎么用?C# ITestFrameworkDiscoveryOptions.MethodDisplayOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITestFrameworkDiscoveryOptions
的用法示例。
在下文中一共展示了ITestFrameworkDiscoveryOptions.MethodDisplayOrDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTestCase
protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) {
if (testMethod.Method.ReturnType.Name == "System.Void" &&
testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) {
return new ExecutionErrorTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, "Async void methods are not supported.");
}
return new LegacyUITestCase(UITestCase.SyncContextType.WPF, diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod);
}
示例2: 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));
}
}
示例3: 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;
}
}
示例4: 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) };
}
示例5: Discover
public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
var maxRetries = factAttribute.GetNamedArgument<int>("MaxRetries");
if (maxRetries < 1)
maxRetries = 3;
yield return new RetryTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, maxRetries);
}
示例6: Discover
public IEnumerable<IXunitTestCase> Discover(
ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
Guard.AgainstNullArgument("discoveryOptions", discoveryOptions);
yield return new ScenarioOutline(
this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod);
}
示例7: Discover
public IEnumerable<IXunitTestCase> Discover(
ITestFrameworkDiscoveryOptions discoveryOptions,
ITestMethod testMethod,
IAttributeInfo factAttribute
)
{
yield return new FarmDependentTestCase(_diagnosticSink, discoveryOptions.MethodDisplayOrDefault(), testMethod);
}
示例8: Discover
public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
if (Helper.Organization == null)
{
return Enumerable.Empty<IXunitTestCase>();
}
return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) };
}
示例9: Discover
/// <summary>
/// Discover test cases from a test method. By default, inspects the test method's argument list
/// to ensure it's empty, and if not, returns a single <see cref="ExecutionErrorTestCase"/>;
/// otherwise, it returns the result of calling <see cref="CreateTestCase"/>.
/// </summary>
/// <param name="discoveryOptions">The discovery options to be used.</param>
/// <param name="testMethod">The test method the test cases belong to.</param>
/// <param name="factAttribute">The fact attribute attached to the test method.</param>
/// <returns>Returns zero or more test cases represented by the test method.</returns>
public virtual IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
var testCase =
testMethod.Method.GetParameters().Any()
? new ExecutionErrorTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, "[Fact] methods are not allowed to have parameters. Did you mean to use [Theory]?")
: CreateTestCase(discoveryOptions, testMethod, factAttribute);
return new[] { testCase };
}
示例10: Discover
public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
var ctorArgs = factAttribute.GetConstructorArguments().ToArray();
var cultures = Reflector.ConvertArguments(ctorArgs, new[] { typeof(string[]) }).Cast<string[]>().Single();
if (cultures == null || cultures.Length == 0)
cultures = new[] { "en-US", "fr-FR" };
return cultures.Select(culture => new CulturedXunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, culture)).ToList();
}
示例11: Discover
public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
if (String.IsNullOrWhiteSpace(Helper.ClientId)
&& String.IsNullOrWhiteSpace(Helper.ClientSecret))
{
return Enumerable.Empty<IXunitTestCase>();
}
return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) };
}
示例12: Discover
public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
if (Helper.Credentials == null)
return Enumerable.Empty<IXunitTestCase>();
if (!Helper.IsPaidAccount)
return Enumerable.Empty<IXunitTestCase>();
return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) };
}
示例13: Discover
public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
var defaultMethodDisplay = discoveryOptions.MethodDisplayOrDefault();
// Unlike fact discovery, the underlying algorithm for theories is complex, so we let the theory discoverer
// do its work, and do a little on-the-fly conversion into our own test cases.
return theoryDiscoverer.Discover(discoveryOptions, testMethod, factAttribute)
.Select(testCase => testCase is XunitTheoryTestCase
? (IXunitTestCase)new SkippableTheoryTestCase(diagnosticMessageSink, defaultMethodDisplay, testCase.TestMethod)
: new SkippableFactTestCase(diagnosticMessageSink, defaultMethodDisplay, testCase.TestMethod, testCase.TestMethodArguments));
}
示例14: Discover
public override IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
if (_databaseExists.Value)
{
return base.Discover(discoveryOptions, testMethod, factAttribute);
}
else
{
return new IXunitTestCase[] { new SkippedTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) };
}
}
示例15: Discover
/// <inheritdoc/>
public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
var methodDisplay = discoveryOptions.MethodDisplayOrDefault();
IXunitTestCase testCase;
if (testMethod.Method.GetParameters().Any())
testCase = new ExecutionErrorTestCase(diagnosticMessageSink, methodDisplay, testMethod, "[Fact] methods are not allowed to have parameters. Did you mean to use [Theory]?");
else
testCase = new XunitTestCase(diagnosticMessageSink, methodDisplay, testMethod);
return new[] { testCase };
}