private static TestCase ExtractTestCase(AttributeSyntax attribute, TestFixtureDetails testFixture, ISemanticModel semanticModel) { var methodDeclarationSyntax = GetAttributeMethod(attribute); bool isAsync = IsAsync(methodDeclarationSyntax); if (isAsync && IsVoid(methodDeclarationSyntax)) return null; var testCase = new TestCase(testFixture); testCase.IsAsync = isAsync; testCase.Arguments = new object[attribute.ArgumentList.Arguments.Count]; for (int i = 0; i < testCase.Arguments.Length; i++) { AttributeArgumentSyntax testCaseArg = attribute.ArgumentList.Arguments[i]; object constantValue = semanticModel.GetConstantValue(testCaseArg.Expression); if (constantValue != null) testCase.Arguments[i] = constantValue; else testCase.Arguments[i] = testCaseArg.Expression.GetFirstToken().Value; } testCase.SyntaxNode = methodDeclarationSyntax; testCase.MethodName = methodDeclarationSyntax.Identifier.ValueText; return testCase; }
private static TestCase ExtractTest(AttributeSyntax attribute, TestFixtureDetails testFixture) { var methodDeclarationSyntax = GetAttributeMethod(attribute); bool isAsync = IsAsync(methodDeclarationSyntax); if (isAsync && IsVoid(methodDeclarationSyntax)) return null; var testCase = new TestCase(testFixture) { SyntaxNode = methodDeclarationSyntax, IsAsync = isAsync, MethodName = methodDeclarationSyntax.Identifier.ValueText, Arguments = new string[0] }; return testCase; }