internal static void RunWithTemporaryPluginFile(Gallio.Common.Action <string, string> action, string pluginFileContents) { var pluginDir = SpecialPathPolicy.For <PluginLoaderTest>().GetTempDirectory().FullName; if (Directory.Exists(pluginDir)) { Directory.Delete(pluginDir, true); } var pluginFile = Path.Combine(pluginDir, "Sample.plugin"); try { Directory.CreateDirectory(pluginDir); System.IO.File.WriteAllText(pluginFile, pluginFileContents); action(pluginDir, pluginFile); } finally { if (Directory.Exists(pluginDir)) { Directory.Delete(pluginDir, true); } } }
public void ShouldWaitForAllActionsToFinishBeforeReturning( [Column(0, 1, 2, 7, 19)] int numActions) { Stopwatch stopwatch = Stopwatch.StartNew(); bool[] finished = new bool[numActions]; Action[] actions = new Action[numActions]; for (int i = 0; i < numActions; i++) { int actionIndex = i; actions[i] = () => { Thread.Sleep((actionIndex + 1) * 71 % 37); TestLog.WriteLine("Iteration #{0} finished after {1}ms", actionIndex + 1, stopwatch.ElapsedMilliseconds); finished[actionIndex] = true; }; } var scheduler = new WorkScheduler(() => maxThreads); scheduler.Run(actions); for (int i = 0; i < numActions; i++) { Assert.IsTrue(finished[i]); } }
private static TimeSpan Time(Action action) { var stopwatch = new Stopwatch(); stopwatch.Start(); action(); stopwatch.Stop(); return(stopwatch.Elapsed); }
public void ConstructorRequiresNameAndExecuteAction() { Assert.Throws <ArgumentNullException>(() => new TestCase(null, delegate { })); Assert.Throws <ArgumentNullException>(() => new TestCase("Foo", null)); Action execute = delegate { }; TestCase testCase = new TestCase("Name", execute); Assert.AreEqual("Name", testCase.Name); Assert.AreSame(execute, testCase.Execute); }
public void SetUp() { TestSuite testSuite = new TestSuite("Name"); Assert.IsNull(testSuite.SetUp); Action action = delegate { }; testSuite.SetUp = action; Assert.AreSame(action, testSuite.SetUp); }
public void SuiteTearDown() { TestSuite testSuite = new TestSuite("Name"); Assert.IsNull(testSuite.SuiteTearDown); Action action = delegate { }; testSuite.SuiteTearDown = action; Assert.AreSame(action, testSuite.SuiteTearDown); }
/// <summary> /// Execute the script and verify it passed /// </summary> /// <param name="testName"></param> /// <returns></returns> public TestOutcome ExecuteScriptAndGetOutcome(string testName) { Action executeTest = delegate { Driver.Connect(host); Driver.ExecuteScript(scriptName, description); VerifySuccess(); AttachTestFiles(); }; return(TestStep.RunStep(testName, executeTest, new TimeSpan(0, 0, timeoutMin, 0), true, null).Outcome); }
private void DoRetry(bool expectedSucceeded, Gallio.Common.Action action) { AssertionFailure[] failures = Capture(action); if (expectedSucceeded) { Assert.IsEmpty(failures); } else { Assert.Count(1, failures); Assert.StartsWith(failures[0].Description, "The 'Retry.Until' operation has failed"); } }
public static AssertionFailure[] Capture(Action action) { AssertionFailure[] failures = AssertionHelper.Eval(action); if (failures.Length != 0) { using (TestLog.BeginSection("Captured Assertion Failures")) { foreach (AssertionFailure failure in failures) failure.WriteTo(TestLog.Default); } } return failures; }
public static AssertionFailure[] Capture(Action action) { AssertionFailure[] failures = AssertionHelper.Eval(action); if (failures.Length != 0) { using (TestLog.BeginSection("Captured Assertion Failures")) { foreach (AssertionFailure failure in failures) { failure.WriteTo(TestLog.Default); } } } return(failures); }
public void ShouldWaitForAllActionsToFinishBeforeReturning( [Column(0, 1, 2, 7, 19)] int numActions) { Stopwatch stopwatch = Stopwatch.StartNew(); bool[] finished = new bool[numActions]; Action[] actions = new Action[numActions]; for (int i = 0; i < numActions; i++) { int actionIndex = i; actions[i] = () => { Thread.Sleep((actionIndex + 1) * 71 % 37); TestLog.WriteLine("Iteration #{0} finished after {1}ms", actionIndex + 1, stopwatch.ElapsedMilliseconds); finished[actionIndex] = true; }; } var scheduler = new WorkScheduler(() => maxThreads); scheduler.Run(actions); for (int i = 0; i < numActions; i++) Assert.IsTrue(finished[i]); }
public void BackgroundTask(Action action) { action(); }
private static TimeSpan Time(Action action) { var stopwatch = new Stopwatch(); stopwatch.Start(); action(); stopwatch.Stop(); return stopwatch.Elapsed; }
public void BackgroundTask(Action action) { action(); }