public void InvokeIfNeededTest1() { Control ctl = new Control(); Action doit = new Action(() => ctl.Text = "Contorl"); InvokeExtension.InvokeIfNeeded(ctl, doit); }
// //编写测试时,还可使用以下特性: // //使用 ClassInitialize 在运行类中的第一个测试前先运行代码 //[ClassInitialize()] //public static void MyClassInitialize(TestContext testContext) //{ //} // //使用 ClassCleanup 在运行完类中的所有测试后再运行代码 //[ClassCleanup()] //public static void MyClassCleanup() //{ //} // //使用 TestInitialize 在运行每个测试前先运行代码 //[TestInitialize()] //public void MyTestInitialize() //{ //} // //使用 TestCleanup 在运行完每个测试后运行代码 //[TestCleanup()] //public void MyTestCleanup() //{ //} // #endregion /// <summary> ///InvokeIfNeeded 的测试 ///</summary> public void InvokeIfNeededTestHelper <T>() { Control ctl = new Control(); Action <string> doit = new Action <string>((item) => ctl.Text = item); string args = "Control"; InvokeExtension.InvokeIfNeeded <string>(ctl, doit, args); }
/// <summary> ///InvokeIfNeeded 的测试 ///</summary> public void InvokeIfNeededTest2Helper <T, S>() { Control ctl = new Control(); Action <string, string> doit = new Action <string, string>((a, b) => { ctl.Text = a; ctl.Tag = b; }); string arg1 = ""; string arg2 = ""; InvokeExtension.InvokeIfNeeded <string, string>(ctl, doit, arg1, arg2); }