本文整理汇总了C#中IPatternScope类的典型用法代码示例。如果您正苦于以下问题:C# IPatternScope类的具体用法?C# IPatternScope怎么用?C# IPatternScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPatternScope类属于命名空间,在下文中一共展示了IPatternScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DecorateAssemblyTest
/// <inheritdoc />
protected override void DecorateAssemblyTest(IPatternScope assemblyScope, IAssemblyInfo assembly)
{
assemblyScope.TestBuilder.TestActions.InitializeTestChain.After(state =>
{
TestAssemblyExecutionParameters.DefaultTestCaseTimeout = Timeout;
});
}
示例2: DecorateAssemblyTest
/// <inheritdoc />
protected override void DecorateAssemblyTest(IPatternScope assemblyScope, IAssemblyInfo assembly)
{
assemblyScope.TestBuilder.TestActions.InitializeTestChain.After(state =>
{
TestAssemblyExecutionParameters.DegreeOfParallelism = degreeOfParallelism;
});
}
示例3: DecorateContainingScope
/// <inheritdoc />
protected override void DecorateContainingScope(IPatternScope containingScope, IMethodInfo methodInfo)
{
Type formattableType = methodInfo.Parameters[0].Resolve(true).ParameterType;
var extensionPoints = (IExtensionPoints)RuntimeAccessor.ServiceLocator.ResolveByComponentId("Gallio.ExtensionPoints");
CustomTestEnvironment.SetUpThreadChain.Before(() => extensionPoints.CustomFormatters.Register(formattableType, x => (string)methodInfo.Resolve(true).Invoke(this, new[] { x })));
CustomTestEnvironment.TeardownThreadChain.After(() => extensionPoints.CustomFormatters.Unregister(formattableType));
}
示例4: 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;
});
}
示例5: Validate
/// <inheritdoc />
protected override void Validate(IPatternScope containingScope, IMethodInfo method)
{
base.Validate(containingScope, method);
if (method.Parameters.Count != 0)
ThrowUsageErrorException("A fixture set-up method must not have any parameters.");
}
示例6: Validate
/// <inheritdoc />
protected override void Validate(IPatternScope containingScope, ITypeInfo type)
{
base.Validate(containingScope, type);
if (type.IsAbstract && type.IsSealed)
ThrowUsageErrorException("This attribute cannot be used on a static class.");
}
示例7: 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));
}
示例8: DecorateContainingScope
/// <inheritdoc />
protected override void DecorateContainingScope(IPatternScope containingScope, IMethodInfo method)
{
containingScope.TestBuilder.TestInstanceActions.InitializeTestInstanceChain.After(
delegate(PatternTestInstanceState testInstanceState)
{
testInstanceState.InvokeFixtureMethod(method, EmptyArray<KeyValuePair<ISlotInfo, object>>.Instance);
});
}
示例9: 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));
}
}
示例10: 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;
}
示例11: DecorateTest
protected override void DecorateTest(IPatternScope scope, ICodeElementInfo codeElement)
{
scope.TestBuilder.TestInstanceActions.DecorateChildTestChain.After(
delegate(PatternTestInstanceState state, PatternTestActions actions)
{
AddDecorator(actions.TestInstanceActions.ExecuteTestInstanceChain);
});
}
示例12: 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);
}
示例13: 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);
foreach (KeyValuePair<string, string> pair in GetMetadata())
scope.TestComponentBuilder.AddMetadata(pair.Key, pair.Value);
}
示例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: PopulateDataSource
/// <inheritdoc />
protected override void PopulateDataSource(IPatternScope scope, DataSource dataSource, ICodeElementInfo codeElement)
{
using (var stream = OpenStream(codeElement))
{
var bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
var dataSet = new ValueSequenceDataSet(new[] { bytes }, null, false);
dataSource.AddDataSet(dataSet);
}
}