本文整理汇总了C#中TestSuite类的典型用法代码示例。如果您正苦于以下问题:C# TestSuite类的具体用法?C# TestSuite怎么用?C# TestSuite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestSuite类属于命名空间,在下文中一共展示了TestSuite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OneTimeTearDownCommand
/// <summary>
/// Construct a OneTimeTearDownCommand
/// </summary>
/// <param name="suite">The test suite to which the command applies</param>
/// <param name="setUpTearDown">A SetUpTearDownList for use by the command</param>
public OneTimeTearDownCommand(TestSuite suite, SetUpTearDownList setUpTearDown)
: base(suite)
{
if (suite.FixtureType != null)
_tearDownMethods = Reflect.GetMethodsWithAttribute(suite.FixtureType, typeof(OneTimeTearDownAttribute), true);
_setUpTearDown = setUpTearDown;
}
示例2: Visit
public virtual void Visit(TestSuite testSuite)
{
foreach (TestUnit child in testSuite.Children)
{
child.Apply(this);
}
}
示例3: AssertTestCase_TestCaseError_StackTraceIsFilledWithXml
public void AssertTestCase_TestCaseError_StackTraceIsFilledWithXml()
{
var sut = "not empty string";
var ctrStub = new Mock<Constraint>();
ctrStub.Setup(c => c.Matches(It.IsAny<object>())).Throws(new ExternalDependencyNotFoundException("Filename"));
var ctr = ctrStub.Object;
var xmlContent = "<test><system></system><assert></assert></test>";
var testSuite = new TestSuite();
try
{
testSuite.AssertTestCase(sut, ctr, xmlContent);
}
catch (CustomStackTraceErrorException ex)
{
Assert.That(ex.StackTrace, Is.EqualTo(xmlContent));
}
catch (Exception ex)
{
if (ex.InnerException==null)
Assert.Fail("The exception should have been an CustomStackTraceErrorException but was {0}.\r\n{1}", new object[] { ex.GetType().FullName, ex.StackTrace });
else
Assert.Fail("The exception should have been an CustomStackTraceErrorException but was something else. The inner exception is {0}.\r\n{1}", new object[] { ex.InnerException.GetType().FullName, ex.InnerException.StackTrace });
}
}
示例4: TearDown
public async Task TearDown (TestSuite suite)
{
if (!Persistent)
await Server.Stop ();
foreach (var extension in HttpClientTestFramework.Extensions)
await extension.TearDown (suite);
}
示例5: TestCreatingTestSuiteForTestCase
public void TestCreatingTestSuiteForTestCase()
{
var suite = new TestSuite();
suite.CreateTestSuiteFor(typeof(DummyTestCase));
Assert.AreEqual(2, suite.Tests.Count);
}
示例6: TestFailsWhenDerivedExceptionIsThrown
public void TestFailsWhenDerivedExceptionIsThrown()
{
TestSuite suite = new TestSuite(typeof(DerivedExceptionThrownClass));
TestResult result = (TestResult)suite.Run().Results[0];
Assert.That(result.ResultState, Is.EqualTo(ResultState.Failure));
Assert.That(result.Message, Is.EqualTo("Expected Exception of type <System.Exception>, but was <System.ApplicationException>"));
}
示例7: MakeOneTimeSetUpCommand
/// <summary>
/// Gets the command to be executed before any of
/// the child tests are run.
/// </summary>
/// <returns>A TestCommand</returns>
public static TestCommand MakeOneTimeSetUpCommand(TestSuite suite, List<SetUpTearDownItem> setUpTearDown, List<TestActionItem> actions)
{
// Handle skipped tests
if (suite.RunState != RunState.Runnable && suite.RunState != RunState.Explicit)
return MakeSkipCommand(suite);
// Build the OneTimeSetUpCommand itself
TestCommand command = new OneTimeSetUpCommand(suite, setUpTearDown, actions);
// Prefix with any IApplyToContext items from attributes
IList<IApplyToContext> changes = null;
if (suite.TypeInfo != null)
changes = suite.TypeInfo.GetCustomAttributes<IApplyToContext>(true);
else if (suite.Method != null)
changes = suite.Method.GetCustomAttributes<IApplyToContext>(true);
else
{
var testAssembly = suite as TestAssembly;
if (testAssembly != null)
#if PORTABLE
changes = new List<IApplyToContext>(testAssembly.Assembly.GetAttributes<IApplyToContext>());
#else
changes = (IApplyToContext[])testAssembly.Assembly.GetCustomAttributes(typeof(IApplyToContext), true);
#endif
}
if (changes != null && changes.Count > 0)
command = new ApplyChangesToContextCommand(command, changes);
return command;
}
示例8: Suite
public static TestSuite Suite()
{
TestSuite suite = new TestSuite("Security Tests");
suite.AddTests(typeof(TestSecurityExceptions));
suite.AddTests(typeof(TestSecurityElement));
return suite;
}
示例9: Start
/**
* Initialize class resources.
*/
void Start()
{
// Create test suite
TestSuite suite = new TestSuite();
// For each assembly in this app domain
foreach (Assembly assem in AppDomain.CurrentDomain.GetAssemblies())
{
// For each type in the assembly
foreach (Type type in assem.GetTypes())
{
// If this is a valid test case
// i.e. derived from TestCase and instantiable
if (typeof(TestCase).IsAssignableFrom(type) &&
type != typeof(TestCase) &&
!type.IsAbstract)
{
// Add tests to suite
suite.AddAll(type.GetConstructor(new Type[0]).Invoke(new object[0]) as TestCase);
}
}
}
// Run the tests
TestResult res = suite.Run(null);
// Report results
Unity3D_TestReporter reporter = new Unity3D_TestReporter();
reporter.LogResults(res);
}
示例10: MakeOneTimeSetUpCommand
/// <summary>
/// Gets the command to be executed before any of
/// the child tests are run.
/// </summary>
/// <returns>A TestCommand</returns>
public static TestCommand MakeOneTimeSetUpCommand(TestSuite suite, List<SetUpTearDownItem> setUpTearDown, List<TestActionItem> actions)
{
// Handle skipped tests
if (suite.RunState != RunState.Runnable && suite.RunState != RunState.Explicit)
return MakeSkipCommand(suite);
// Build the OneTimeSetUpCommand itself
TestCommand command = new OneTimeSetUpCommand(suite, setUpTearDown, actions);
// Prefix with any IApplyToContext items from attributes
if (suite.TypeInfo != null)
{
IApplyToContext[] changes = suite.TypeInfo.GetCustomAttributes<IApplyToContext>(true);
if (changes.Length > 0)
command = new ApplyChangesToContextCommand(command, changes);
}
if (suite.Method!=null)
{
IApplyToContext[] changes = suite.Method.GetCustomAttributes<IApplyToContext>(true);
if (changes.Length > 0)
command = new ApplyChangesToContextCommand(command, changes);
}
return command;
}
示例11: Suite
public static TestSuite Suite()
{
TestSuite suite = new TestSuite("Core Class Tests");
#if CONFIG_FRAMEWORK_2_0
suite.AddTests(typeof(TestActivationArguments));
suite.AddTests(typeof(TestActivationContext));
suite.AddTests(typeof(TestApplicationId));
suite.AddTests(typeof(TestApplicationIdentity));
#endif
suite.AddTests(typeof(TestArgIterator));
suite.AddTests(typeof(TestArray));
suite.AddTests(typeof(TestAttribute));
suite.AddTests(typeof(TestBoolean));
suite.AddTests(typeof(TestConvert));
suite.AddTests(typeof(TestDecimal));
suite.AddTests(typeof(TestDelegate));
suite.AddTests(typeof(TestDouble));
suite.AddTests(typeof(TestSByte));
suite.AddTests(typeof(TestString));
#if !ECMA_COMPAT
suite.AddTests(typeof(TestGuid));
#endif
suite.AddTests(typeof(TestSystemExceptions));
suite.AddTests(typeof(TestVersion));
return suite;
}
示例12: AddChildToTestCase
public void AddChildToTestCase()
{
TestSuite master = new TestSuite("master", null);
TestCase test = new TestCase("test", master);
test.AddChild(new TestCase());
}
示例13: BenchmarkStringJoin
private static void BenchmarkStringJoin(string[] testData, string expectedData)
{
var testName = String.Format("Joining strings - with {0} string", testData.Length);
// Create a TestSuite class for a group of BenchmarTests
var benchmarkSuite = new TestSuite<string[], string>(testName)
// You don't have to specify a method group - but you'll probably want to give an explicit name if you use
.Plus(input => String.Join(" ", input), "String.Join")
.Plus(LoopingWithStringBuilderCommumUsage)
.Plus(input => LoopingWithStringBuilderWithInitialCapacity(input, expectedData.Length + 2), "LoopingWithStringBuilderWithInitialCapacity")
.Plus(LoopingWithStringBuilderWithInitialValue)
.Plus(input => LoopingWithStringBuilderWithInitialValueAndCapacity(input, expectedData.Length + 2), "LoopingWithStringBuilderWithInitialValueAndCapacity")
.Plus(LoopingWithStringConcatenation)
.Plus(LoopingWithStringConcat)
.Plus(LoopingWithStringFormat);
// This returns a ResultSuite
var resultsSmallData = benchmarkSuite.RunTests(testData, expectedData)
// Again, scaling returns a new ResultSuite, with all the results scaled
// - in this case they'll all have the same number of iterations
.ScaleByBest(ScalingMode.VaryDuration);
// There are pairs for name and score, iterations or duration - but we want name, duration *and* score
resultsSmallData.Display(ResultColumns.NameAndDuration | ResultColumns.Score,
// Scale the scores to make the best one get 1.0
resultsSmallData.FindBest());
}
示例14: OneTimeSetUpCommand
/// <summary>
/// Constructs a OneTimeSetUpComand for a suite
/// </summary>
/// <param name="suite">The suite to which the command applies</param>
public OneTimeSetUpCommand(TestSuite suite)
: base(suite)
{
this.suite = suite;
this.fixtureType = suite.FixtureType;
this.arguments = suite.arguments;
}
示例15: AssertTestCase_TestCaseError_MessageIsAvailable
public void AssertTestCase_TestCaseError_MessageIsAvailable()
{
var sut = "not empty string";
var ctrStub = new Mock<Constraint>();
ctrStub.Setup(c => c.Matches(It.IsAny<object>())).Throws(new ExternalDependencyNotFoundException("Filename"));
var ctr = ctrStub.Object;
var xmlContent = "<test><system></system><assert></assert></test>";
var testSuite = new TestSuite();
try
{
testSuite.AssertTestCase(sut, ctr, xmlContent);
}
catch (CustomStackTraceErrorException ex)
{
Console.WriteLine(ex.Message);
Assert.That(ex.Message, Is.StringContaining("Filename"));
}
catch (Exception ex)
{
Assert.Fail("The exception should have been a CustomStackTraceErrorException but was {0}.", new object[] { ex.GetType().FullName });
}
}