Changeset 15287 for trunk/sources/HeuristicLab.Tests
- Timestamp:
- 07/26/17 15:48:32 (7 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
/branches/Async (added) merged: 13329,13349,13354-13355,13401,15065,15190,15204,15212,15215-15216,15232,15280-15281,15284,15286
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Tests
- Property svn:mergeinfo changed
/branches/Async/HeuristicLab.Tests (added) merged: 13355,13401,15065,15280-15281
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Tests/HeuristicLab-3.3/CollectObjectGraphTest.cs
r14185 r15287 24 24 using System.Diagnostics; 25 25 using System.Linq; 26 using System.Threading;27 26 using System.Threading.Tasks; 28 27 using HeuristicLab.Algorithms.GeneticAlgorithm; … … 125 124 algs.Add(ga); 126 125 127 var cancellationTokenSource = new CancellationTokenSource(); 128 ga.StartSync(cancellationTokenSource.Token); 126 ga.Start(); 129 127 sw.Stop(); 130 128 TestContext.WriteLine("{0}: {1} ", i, sw.Elapsed); … … 157 155 var sw = new Stopwatch(); 158 156 sw.Start(); 159 ga.Start Sync(new CancellationToken());157 ga.Start(); 160 158 sw.Stop(); 161 159 Console.WriteLine("{0}; Objects after execution: {1}", ga.Name, ga.GetObjectGraphObjects().Count()); -
trunk/sources/HeuristicLab.Tests/HeuristicLab-3.3/GeneticAlgorithmTest.cs
r14185 r15287 21 21 22 22 using System; 23 using System.Threading;24 23 using HeuristicLab.Algorithms.GeneticAlgorithm; 25 24 using HeuristicLab.Common; … … 39 38 } 40 39 41 private EventWaitHandle trigger = new AutoResetEvent(false);42 40 private Exception ex; 43 41 … … 49 47 GeneticAlgorithm ga = (GeneticAlgorithm)XmlParser.Deserialize(@"Test Resources\GA_TSP.hl"); 50 48 ga.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(ga_ExceptionOccurred); 51 ga.Stopped += new EventHandler(ga_Stopped);52 49 ga.SetSeedRandomly.Value = false; 53 50 ga.Seed.Value = 0; … … 55 52 ga.Prepare(); 56 53 ga.Start(); 57 trigger.WaitOne();58 54 if (ex != null) throw ex; 59 55 … … 80 76 ex = e.Value; 81 77 } 82 83 private void ga_Stopped(object sender, EventArgs e) {84 trigger.Set();85 }86 78 } 87 79 } -
trunk/sources/HeuristicLab.Tests/HeuristicLab-3.3/Samples/SamplesUtils.cs
r13237 r15287 1 1 using System; 2 2 using System.Linq; 3 using System.Threading;4 3 using HeuristicLab.Algorithms.ALPS; 5 4 using HeuristicLab.Algorithms.EvolutionStrategy; … … 18 17 19 18 public static void RunAlgorithm(IAlgorithm a) { 20 var trigger = new EventWaitHandle(false, EventResetMode.ManualReset);21 19 Exception ex = null; 22 a.Stopped += (src, e) => { trigger.Set(); }; 23 a.ExceptionOccurred += (src, e) => { ex = e.Value; trigger.Set(); }; 20 a.ExceptionOccurred += (sender, e) => { ex = e.Value; }; 24 21 a.Prepare(); 25 22 a.Start(); 26 trigger.WaitOne(); 27 28 Assert.AreEqual(ex, null); 23 Assert.IsNull(ex); 29 24 } 30 25 -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/GaussianProcessRegressionTest.cs
r14185 r15287 22 22 using System; 23 23 using System.Linq; 24 using System.Threading;25 24 using HeuristicLab.Common; 26 25 using HeuristicLab.Problems.DataAnalysis; … … 39 38 } 40 39 41 private EventWaitHandle trigger = new AutoResetEvent(false);42 40 private Exception ex; 43 41 … … 66 64 67 65 alg.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(cv_ExceptionOccurred); 68 alg.Stopped += new EventHandler(cv_Stopped);69 66 70 67 alg.Prepare(); 71 68 alg.Start(); 72 trigger.WaitOne();73 69 if (ex != null) throw ex; 74 70 … … 79 75 ex = e.Value; 80 76 } 81 82 private void cv_Stopped(object sender, EventArgs e) {83 trigger.Set();84 }85 77 } 86 78 } -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/GradientBoostingTest.cs
r13895 r15287 3 3 using System.IO; 4 4 using System.Linq; 5 using System.Threading;6 5 using HeuristicLab.Data; 7 using HeuristicLab.Optimization;8 6 using HeuristicLab.Problems.DataAnalysis; 9 7 using Microsoft.VisualStudio.TestTools.UnitTesting; … … 242 240 #endregion 243 241 244 RunAlgorithm(gbt);242 gbt.Start(); 245 243 246 244 Console.WriteLine(gbt.ExecutionTime); … … 270 268 #endregion 271 269 272 RunAlgorithm(gbt);270 gbt.Start(); 273 271 274 272 Console.WriteLine(gbt.ExecutionTime); … … 298 296 #endregion 299 297 300 RunAlgorithm(gbt);298 gbt.Start(); 301 299 302 300 Console.WriteLine(gbt.ExecutionTime); 303 301 Assert.AreEqual(0.061954221604374943, ((DoubleValue)gbt.Results["Loss (train)"].Value).Value, 1E-6); 304 302 Assert.AreEqual(0.06316303473499961, ((DoubleValue)gbt.Results["Loss (test)"].Value).Value, 1E-6); 305 }306 307 // same as in SamplesUtil308 private void RunAlgorithm(IAlgorithm a) {309 var trigger = new EventWaitHandle(false, EventResetMode.ManualReset);310 Exception ex = null;311 a.Stopped += (src, e) => { trigger.Set(); };312 a.ExceptionOccurred += (src, e) => { ex = e.Value; trigger.Set(); };313 a.Prepare();314 a.Start();315 trigger.WaitOne();316 317 Assert.AreEqual(ex, null);318 303 } 319 304 -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/SupportVectorMachineTest.cs
r14185 r15287 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Threading;26 25 using HeuristicLab.Algorithms.DataAnalysis; 27 26 using HeuristicLab.Common; … … 50 49 } 51 50 52 private EventWaitHandle trigger = new AutoResetEvent(false);53 51 private Exception ex; 54 52 … … 71 69 72 70 cv.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(cv_ExceptionOccurred); 73 cv.Stopped += new EventHandler(cv_Stopped);74 71 75 72 cv.Prepare(); 76 73 cv.Start(); 77 trigger.WaitOne();78 74 if (ex != null) throw ex; 79 75 … … 102 98 ex = e.Value; 103 99 } 104 105 private void cv_Stopped(object sender, EventArgs e) {106 trigger.Set();107 }108 100 } 109 101 } -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Script Sources/GUIAutomationScriptSource.cs
r11789 r15287 1 using System; 2 using System.Linq; 3 using System.Threading; 1 using System.Linq; 4 2 using System.Windows.Forms; 5 3 6 4 using HeuristicLab.Algorithms.GeneticAlgorithm; 7 using HeuristicLab.Core;8 5 using HeuristicLab.MainForm; 9 6 using HeuristicLab.MainForm.WindowsForms; … … 13 10 14 11 public class GUIAutomationScript : HeuristicLab.Scripting.CSharpScriptBase { 15 readonly ManualResetEvent mutex = new ManualResetEvent(false);16 17 12 public override void Main() { 18 13 var ga = new GeneticAlgorithm { … … 27 22 ga.PopulationSize.Value *= 2; 28 23 } 29 30 experiment.ExecutionStateChanged += OnExecutionStateChanged;31 24 experiment.Start(); 32 mutex.WaitOne();33 25 34 26 vars.experiment = experiment; … … 39 31 bubbleChart.Controls.OfType<ComboBox>().Single(x => x.Name == "xAxisComboBox").SelectedItem = "PopulationSize"; 40 32 } 41 42 private void OnExecutionStateChanged(object sender, EventArgs e) {43 if (((IExecutable)sender).ExecutionState == ExecutionState.Stopped)44 mutex.Set();45 }46 33 } -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/ScriptingUtils.cs
r14185 r15287 21 21 22 22 using System; 23 using System.Threading;24 23 using HeuristicLab.Scripting; 25 24 using Microsoft.VisualStudio.TestTools.UnitTesting; … … 33 32 34 33 public static void RunScript(CSharpScript s) { 35 var trigger = new EventWaitHandle(false, EventResetMode.ManualReset);36 34 Exception ex = null; 37 38 s.ScriptExecutionFinished += (sender, e) => { ex = e.Value; trigger.Set(); }; 39 s.ExecuteAsync(); 40 trigger.WaitOne(); 41 35 s.ScriptExecutionFinished += (sender, e) => { ex = e.Value; }; 36 s.Execute(); 42 37 Assert.IsNull(ex); 43 38 } -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj
r15235 r15287 446 446 <ItemGroup> 447 447 <Compile Include="AssemblyInitializer.cs" /> 448 <Compile Include="HeuristicLab-3.3\AlgorithmExtensions.cs" />449 448 <Compile Include="HeuristicLab-3.3\CloningConstructorTest.cs" /> 450 449 <Compile Include="HeuristicLab-3.3\CollectObjectGraphTest.cs" />
Note: See TracChangeset
for help on using the changeset viewer.