本文整理汇总了C#中ICodeElementInfo类的典型用法代码示例。如果您正苦于以下问题:C# ICodeElementInfo类的具体用法?C# ICodeElementInfo怎么用?C# ICodeElementInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICodeElementInfo类属于命名空间,在下文中一共展示了ICodeElementInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExploreImpl
protected override void ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
{
InitializeExplorerIfNeeded(reflectionPolicy);
IAssemblyInfo assembly = ReflectionUtils.GetAssembly(codeElement);
if (assembly != null)
{
bool skipChildren = ! (codeElement is IAssemblyInfo);
if (BuildAssemblyTest(assembly, skipChildren))
{
foreach (IPatternScope scope in evaluator.GetScopes(assembly))
scope.PopulateDeferredComponents(null);
assemblies[assembly] = true;
}
else
{
ITypeInfo type = ReflectionUtils.GetType(codeElement);
if (type != null)
{
foreach (IPatternScope scope in evaluator.GetScopes(assembly))
scope.PopulateDeferredComponents(type);
}
}
}
}
示例2: ContractVerificationContext
/// <summary>
/// Constructs an execution context for the verification tests of a contract verifier.
/// </summary>
/// <param name="codeElement">The code element for the contract read-only field.</param>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="codeElement"/> is null.</exception>
public ContractVerificationContext(ICodeElementInfo codeElement)
{
if (codeElement == null)
throw new ArgumentNullException("codeElement");
this.codeElement = codeElement;
}
示例3: Annotation
/// <summary>
/// Creates an annotation with a detail message string.
/// </summary>
/// <param name="type">The annotation type.</param>
/// <param name="codeElement">The associated code element, or null if none.</param>
/// <param name="message">The annotation message.</param>
/// <param name="details">Additional details such as exception text or null if none.</param>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="message"/> is null.</exception>
public Annotation(AnnotationType type, ICodeElementInfo codeElement, string message, string details)
{
this.type = type;
this.codeElement = codeElement;
this.message = message;
this.details = details;
}
示例4: CreateFromTest
public static GallioTestElement CreateFromTest(TestData test, ICodeElementInfo codeElement, IUnitTestProvider provider,
GallioTestElement parent)
{
if (test == null)
throw new ArgumentNullException("test");
// The idea here is to generate a test element object that does not retain any direct
// references to the code element info and other heavyweight objects. A test element may
// survive in memory for quite a long time so we don't want it holding on to all sorts of
// irrelevant stuff. Basically we flatten out the test to just those properties that we
// need to keep.
var element = new GallioTestElement(provider, parent,
test.Id,
test.Name,
test.Metadata.GetValue(MetadataKeys.TestKind) ?? "Unknown",
test.IsTestCase,
ReSharperReflectionPolicy.GetProject(codeElement),
ReSharperReflectionPolicy.GetDeclaredElementResolver(codeElement),
GetAssemblyPath(codeElement),
GetTypeName(codeElement),
GetNamespaceName(codeElement));
var categories = test.Metadata[MetadataKeys.Category];
if (categories.Count != 0)
element.Categories = UnitTestElementCategory.Create(categories);
var reason = test.Metadata.GetValue(MetadataKeys.IgnoreReason);
if (reason != null)
element.ExplicitReason = reason;
return element;
}
示例5: DecorateTest
/// <inheritdoc />
protected override void DecorateTest(IPatternScope scope, ICodeElementInfo codeElement)
{
scope.TestBuilder.TestInstanceActions.RunTestInstanceBodyChain.Around(delegate(PatternTestInstanceState state, Func<PatternTestInstanceState, TestOutcome> inner)
{
TestOutcome outcome = TestOutcome.Passed;
int passedCount = 0;
for (int i = 0; i < numRepetitions; i++)
{
string name = String.Format("Repetition #{0}", i + 1);
TestContext context = TestStep.RunStep(name, delegate
{
TestOutcome innerOutcome = inner(state);
if (innerOutcome.Status != TestStatus.Passed)
throw new SilentTestException(innerOutcome);
}, null, false, codeElement);
outcome = outcome.CombineWith(context.Outcome);
if (context.Outcome.Status == TestStatus.Passed)
passedCount += 1;
}
TestLog.WriteLine(String.Format("{0} of {1} repetitions passed.",
passedCount, numRepetitions));
return outcome;
});
}
示例6: OpenXDocument
/// <summary>
/// Uses the existing Gallio plumbing to locate files
/// </summary>
protected XDocument OpenXDocument(ICodeElementInfo codeElement)
{
using (TextReader reader = OpenTextReader(codeElement))
{
return XDocument.Load(reader);
}
}
示例7: PopulateDataSource
/// <inheritdoc />
protected override void PopulateDataSource(IPatternScope scope, DataSource dataSource, ICodeElementInfo codeElement)
{
var invoker = new FixtureMemberInvoker<IEnumerable>(factoryType, scope, factoryMethodName);
XDocument xdocument = OpenXDocument(codeElement);
var parameters = new object[] { GetElementList(xdocument, xPath) };
var dataSet = new FactoryDataSet(() => invoker.Invoke(parameters), kind, columnCount);
dataSource.AddDataSet(dataSet);
}
示例8: Process
/// <inheritdoc />
public override void Process(IPatternScope scope, ICodeElementInfo codeElement)
{
//TODO: Review: Issue 762: Shouldn't the base method be invoked here?
//base.Process(scope, codeElement);
Validate(scope, codeElement);
scope.TestComponentBuilder.Name = name;
}
示例9: Consume
/// <inheritdoc />
public override void Consume(IPatternScope containingScope, ICodeElementInfo codeElement, bool skipChildren)
{
//TODO: Review: Issue 762: Shouldn't the base method be invoked here?
//base.Consume(containingScope, codeElement, skipChildren);
var method = codeElement as IMethodInfo;
Validate(containingScope, method);
containingScope.TestComponentBuilder.AddDeferredAction(codeElement, Order, () => DecorateContainingScope(containingScope, method));
}
示例10: DecorateTest
protected override void DecorateTest(IPatternScope scope, ICodeElementInfo codeElement)
{
scope.TestBuilder.TestInstanceActions.DecorateChildTestChain.After(
delegate(PatternTestInstanceState state, PatternTestActions actions)
{
AddDecorator(actions.TestInstanceActions.ExecuteTestInstanceChain);
});
}
示例11: PopulateDataSource
protected override void PopulateDataSource(IPatternScope scope, DataSource dataSource, ICodeElementInfo codeElement)
{
for (int i = 1; i <= count; i++)
{
var row = new object[] { i, "Hello from #" + i };
dataSource.AddDataSet(new ItemSequenceDataSet(new IDataItem[] { new ListDataItem<object>(row, GetMetadata(), false) }, row.Length));
}
}
示例12: GetPatterns
/// <inheritdoc />
public IEnumerable<IPattern> GetPatterns(ICodeElementInfo codeElement)
{
if (codeElement == null)
throw new ArgumentNullException("codeElement");
foreach (PatternAttribute attribute in AttributeUtils.GetAttributes<PatternAttribute>(codeElement, true))
yield return attribute;
}
示例13: XunitTest
/// <summary>
/// Initializes a test initially without a parent.
/// </summary>
/// <param name="name">The name of the component.</param>
/// <param name="codeElement">The point of definition, or null if none.</param>
/// <param name="typeInfo">The Xunit test type information.</param>
/// <param name="methodInfo">The Xunit test method information, or null if none.</param>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="name"/> or <paramref name="typeInfo"/> is null.</exception>
public XunitTest(string name, ICodeElementInfo codeElement, XunitTypeInfoAdapter typeInfo, XunitMethodInfoAdapter methodInfo)
: base(name, codeElement)
{
if (typeInfo == null)
throw new ArgumentNullException(@"typeInfo");
this.typeInfo = typeInfo;
this.methodInfo = methodInfo;
}
示例14: PopulateDataSource
/// <inheritdoc />
protected override void PopulateDataSource(IPatternScope scope, DataSource dataSource, ICodeElementInfo codeElement)
{
using (var textReader = OpenTextReader(codeElement))
{
var text = textReader.ReadToEnd();
var dataSet = new ValueSequenceDataSet(new[] { text }, null, false);
dataSource.AddDataSet(dataSet);
}
}
示例15: GetTestParts
/// <inheritdoc />
public IList<TestPart> GetTestParts(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
{
if (reflectionPolicy == null)
throw new ArgumentNullException("reflectionPolicy");
if (codeElement == null)
throw new ArgumentNullException("codeElement");
return GetTestPartsImpl(reflectionPolicy, codeElement);
}