public PipeLineTestor() { _Func = new TestFunction<int, int>(a => a * 5); _Func2 = new TestFunction<int, int>(a => a - 2); _Func3 = new TestFunction<int, int>(a => a + 2); _Func4 = new TestFunction<int, int>(a => { Thread.Sleep(300); return a * 3; }); _Act = new TestAction<int>(); _Act2 = new TestAction<int>(); _Act3 = new TestAction<int>(a => { Thread.Sleep(300); }); }
public void ToIntTest() { TestFunction target = new TestFunction(); string value = "5"; int expected = 5;//预期的值 int actual;//实际的值 actual = target.ToInt(value); Assert.AreEqual(expected, actual); value = "5.5"; expected = 5; actual = target.ToInt(value); Assert.AreEqual(expected, actual); }
public ScratchyPromise When(TestFunction test) { this.whileTest = test; return this; }
private static void Run <TConfig>( string name, TestFunction func, XmlCheckFunction check) where TConfig : ConfigProvider, new() { Run <TConfig>(new TestLabel(name), func, check); }
private static void Run <TConfig>(TestLabel label, TestFunction func) where TConfig : ConfigProvider, new() { Run <TConfig>(label, func, null); }
private static void Run <TConfig>(string name, TestFunction func) where TConfig : ConfigProvider, new() { Run <TConfig>(new TestLabel(name), func, null); }
public TestScriptTests() { var testStep1 = new TestStep { Command = "command_1", Parameters = "parameters_1, parameters_2" }; var testStep2 = new TestStep { Command = "command_2", Parameters = "parameters_1, parameters_2" }; var testScenario1 = new TestScenario { Name = "Test Scenario 1", State = TestScenarioStates.Run, TestSteps = new List <TestStep>() }; testScenario1.TestSteps.Add(testStep1); testScenario1.TestSteps.Add(testStep2); var testScenario2 = new TestScenario { Name = "Test Scenario 2", State = TestScenarioStates.Run, TestSteps = new List <TestStep>() }; testScenario2.TestSteps.Add(testStep1); testScenario2.TestSteps.Add(testStep2); var testSuite = new TestSuite { Name = "Test Suite 1", TestScenarios = new List <TestScenario>() }; testSuite.TestScenarios.Add(testScenario1); testSuite.TestScenarios.Add(testScenario2); var testFunction1 = new TestFunction { Name = "Test Scenario 1", TestSteps = new List <TestStep>() }; testFunction1.TestSteps.Add(testStep1); testFunction1.TestSteps.Add(testStep2); var testFunctionGroup = new TestFunctionGroup { Name = "Test Suite 1", TestFunctions = new List <TestFunction>() }; testFunctionGroup.TestFunctions.Add(testFunction1); _testScript = new TestScript { TestSuites = new List <TestSuite>(), TestFunctionGroups = new List <TestFunctionGroup>() }; _testScript.TestSuites.Add(testSuite); _testScript.TestFunctionGroups.Add(testFunctionGroup); }
private void TestInAllBrowsers(TestFunction function) { List<string> errors = new List<string>(); IWebDriver driver = null; IJavaScriptExecutor js; try { using (driver = SetupDriver(new FirefoxDriver())) { js = driver as IJavaScriptExecutor; function(js); driver.Close(); driver = null; } } catch (Exception ex) { errors.Add("Firefox Error:" + Environment.NewLine + ex.Message); } try { using (driver = SetupDriver(new InternetExplorerDriver())) { js = driver as IJavaScriptExecutor; function(js); driver.Close(); } } catch (Exception ex) { errors.Add("IE error:" + Environment.NewLine + ex.Message); } /*try { using (driver = SetupDriver(new ChromeDriver())) { js = driver as IJavaScriptExecutor; function(js); driver.Close(); } } catch (Exception ex) { errors.Add("Chrome Errors:" + Environment.NewLine + ex.Message); } try { using (driver = SetupDriver(new SafariDriver())) { js = driver as IJavaScriptExecutor; function(js); driver.Close(); } } catch (Exception ex) { errors.Add(ex.Message); }*/ if (errors.Any()) Assert.Fail(errors.Aggregate((s, x) => s + Environment.NewLine + x)); }
public Test(string Name, TestFunction TestFunc) { this.Name = Name; this.Function += TestFunc; }
public double[] Evaluate(RealVector individual) { return(TestFunction.Evaluate(individual, Objectives)); }