本文整理汇总了C#中TestMethod类的典型用法代码示例。如果您正苦于以下问题:C# TestMethod类的具体用法?C# TestMethod怎么用?C# TestMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestMethod类属于命名空间,在下文中一共展示了TestMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteMethodThrowsException
public void ExecuteMethodThrowsException() {
var fixture = new TestFixture(typeof(Foo));
var tm = new TestMethod(fixture, typeof(Foo).GetMethod("MethodWithException"));
tm.Execute(_listener);
Assert.Equals(" MethodWithException", _sequence);
Assert.StartsWith(" TS:MethodWithException TE:MethodWithException ", SimpleTestListener.Messages);
}
示例2: TestRepository
public TestRepository(ILdapManager ldapManagerObj, TestUserRepository testUserRepository)
{
_testImplementation = new TestImplementation.TestImplementation(testUserRepository, ldapManagerObj);
TestList = new Dictionary<TestType, TestMethod>
{
{TestType.TestAdminConnection, _testImplementation.TestAdminConnect},
{TestType.TestCreateUser, _testImplementation.TestCreateUser},
{TestType.TestDeleteUser, _testImplementation.TestDeleteUser},
{TestType.TestInitLibrary, _testImplementation.TestCompleteInitLibrary},
{TestType.TestInitLibraryNoAdmin, _testImplementation.TestStardardInitLibraryNoAdmin},
{TestType.TestModifyUserDescription, _testImplementation.TestModifyUserAttribute},
{TestType.TestSearchUsers, _testImplementation.TestSearchUser},
{TestType.TestStandardInitLibraryNoAdmin, _testImplementation.TestStardardInitLibraryNoAdmin},
{TestType.TestUserChangePassword, _testImplementation.TestChangeUserPassword},
{
TestType.TestConnectUser, () =>
{
var testMethod = new TestMethod(_testImplementation.TestUserConnectWithoutWritePermissions);
if (_writePermission) testMethod = _testImplementation.TestUserConnect;
return testMethod();
}
},
{
TestType.TestSearchUserAndConnect, () =>
{
var testMethod =
new TestMethod(_testImplementation.TestSearchUserAndConnectWithoutWritePermissions);
if (_writePermission) testMethod = _testImplementation.TestSearchUserAndConnect;
return testMethod();
}
}
};
}
示例3: ShouldNotIgnoreMethodNotMarkedIgnore
public void ShouldNotIgnoreMethodNotMarkedIgnore()
{
MethodInfo methodInfo = typeof(TestMethodTest).GetMethod("MethodNotMarkedIgnore");
var testMethod = new TestMethod(methodInfo);
Assert.IsFalse(testMethod.Ignore);
}
示例4: MSTestAutomation
/// <summary>
/// Initializes a new <see cref="MSTestAutomation"/>.
/// </summary>
public MSTestAutomation(TestMethod testMethod)
{
Name = String.Format("{0}.{1}", testMethod.FullClassName, testMethod.Name);
Identifier = _identifierFactory.CreateIdentifier(Name);
Storage = Path.GetFileName(testMethod.AssemblyName);
TestType = "Unit Test";
}
示例5: MakeTestCommand
/// <summary>
/// Creates a test command for use in running this test.
/// </summary>
/// <returns></returns>
public static TestCommand MakeTestCommand(TestMethod test)
{
// Command to execute test
TestCommand command = new TestMethodCommand(test);
// Add any wrappers to the TestMethodCommand
foreach (IWrapTestMethod wrapper in test.Method.GetCustomAttributes(typeof(IWrapTestMethod), true))
command = wrapper.Wrap(command);
// Wrap in TestActionCommand
command = new TestActionCommand(command);
// Wrap in SetUpTearDownCommand
command = new SetUpTearDownCommand(command);
// Add wrappers that apply before setup and after teardown
foreach (ICommandWrapper decorator in test.Method.GetCustomAttributes(typeof(IWrapSetUpTearDown), true))
command = decorator.Wrap(command);
// Add command to set up context using attributes that implement IApplyToContext
IApplyToContext[] changes = (IApplyToContext[])test.Method.GetCustomAttributes(typeof(IApplyToContext), true);
if (changes.Length > 0)
command = new ApplyChangesToContextCommand(command, changes);
return command;
}
示例6: ExecuteMethod
public void ExecuteMethod() {
var fixture = new TestFixture(typeof(Foo));
var tm = new TestMethod(fixture, typeof(Foo).GetMethod("AMethod"));
tm.Execute( _listener);
Assert.Equals(" AMethod", _sequence);
Assert.Equals(" TS:AMethod TP:AMethod", SimpleTestListener.Messages);
}
示例7: DoTimedRun
public static void DoTimedRun(TestMethod testMethod, int reps)
{
System.GC.Collect();
long rigging_time = 0;
long start;
long finish;
// start = System.DateTime.Now.Ticks;
// for (int i = 1; i <= reps; i++)
// {
// new TestMethod(DoNothingTestMethod)();
// }
// finish = System.DateTime.Now.Ticks;
// rigging_time = (finish - start);
Console.Out.Write("TIME: {0}", testMethod.Method.Name);
start = System.DateTime.Now.Ticks;
for (int i = 1; i <= reps; i++)
{
testMethod();
}
finish = System.DateTime.Now.Ticks;
long millis = ((finish - start) - rigging_time) / TimeSpan.TicksPerMillisecond;
Console.Out.WriteLine("; repeats = {0} {1}ms ({2} millisec/eval)", reps, millis, (millis/reps));
}
示例8: SetUp
public void SetUp()
{
_test = new TestMethod(new MethodWrapper(typeof(DummySuite), "DummyMethod"));
_testResult = _test.MakeTestResult();
_suite = new TestSuite(typeof(DummySuite));
_suiteResult = (TestSuiteResult)_suite.MakeTestResult();
}
示例9: OneNameCriterion
public void OneNameCriterion() {
ITestMethod tm =
new TestMethod(new TestFixture(typeof(SampleTestFixture)),
typeof(SampleTestFixture).GetMethod("Foo"));
var nameCriterion = new NameCriterion(typeof(SampleTestFixture).FullName + ".Foo");
var selection = new TestRun(nameCriterion);
Assert.True(selection.Contains(tm));
}
示例10: SetsTestClassOnTestMethods
public void SetsTestClassOnTestMethods()
{
TestMethod testMethod = new TestMethod(null, null, null);
var testClass = new TestClass("typeName", new[] { testMethod });
Assert.Same(testClass, testMethod.TestClass);
}
示例11: Main
static void Main(string[] args)
{
Program program = new Program();
TestMethod testMethod = new TestMethod(program.SearchShopbyFood);
//program.OptimisticConcurrencyTest();
testMethod += program.SearchShopbyFood3;
testMethod();
}
示例12: DoTest
public void DoTest(IWin32Window owner, TestMethod method, object data)
{
_alarming = true;
_method = method;
_data = data;
MakePrompt();
ShowDialog(owner);
}
示例13: TestSkipped
protected override void TestSkipped(TestMethod method, TestSkippedResult result)
{
Console.WriteLine(
"##teamcity[testIgnored name='{0}' message='{1}']",
Escape(method.DisplayName),
Escape(result.Reason)
);
}
示例14: OneTestConfigured
public void OneTestConfigured() {
var testSpec = new TestSpec();
var testMethod1 = new TestMethod(new TestFixture(typeof(Foo)), typeof(Foo).GetMethod("Bar"));
var testMethod2 = new TestMethod(new TestFixture(typeof(Foo)), typeof(Foo).GetMethod("Nope"));
testSpec.AddTest(testMethod1);
Assert.True(testSpec.Contains(testMethod1));
Assert.False(testSpec.Contains(testMethod2));
}
示例15: RunTest
public static void RunTest(TestMethod r)
{
try
{
r();
}
catch (TestFailedException) { }
}