Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.SGA/3.3/Tests/UnitTest.cs @ 2833

Last change on this file since 2833 was 2830, checked in by swagner, 15 years ago

Operator architecture refactoring (#95)

  • worked on operators and SGA
  • improved performance
File size: 2.1 KB
Line 
1using System;
2using System.Diagnostics;
3using System.Threading;
4using HeuristicLab.Core;
5using HeuristicLab.Persistence.Default.Xml;
6using Microsoft.VisualStudio.TestTools.UnitTesting;
7
8namespace HeuristicLab.SGA.UnitTest {
9  /// <summary>
10  /// Summary description for UnitTest1
11  /// </summary>
12  [TestClass]
13  public class UnitTest {
14    public UnitTest() {
15      //
16      // TODO: Add constructor logic here
17      //
18    }
19
20    private TestContext testContextInstance;
21
22    /// <summary>
23    ///Gets or sets the test context which provides
24    ///information about and functionality for the current test run.
25    ///</summary>
26    public TestContext TestContext {
27      get {
28        return testContextInstance;
29      }
30      set {
31        testContextInstance = value;
32      }
33    }
34
35    #region Additional test attributes
36    //
37    // You can use the following additional attributes as you write your tests:
38    //
39    // Use ClassInitialize to run code before running the first test in the class
40    // [ClassInitialize()]
41    // public static void MyClassInitialize(TestContext testContext) { }
42    //
43    // Use ClassCleanup to run code after all tests in a class have run
44    // [ClassCleanup()]
45    // public static void MyClassCleanup() { }
46    //
47    // Use TestInitialize to run code before running each test
48    // [TestInitialize()]
49    // public void MyTestInitialize() { }
50    //
51    // Use TestCleanup to run code after each test has run
52    // [TestCleanup()]
53    // public void MyTestCleanup() { }
54    //
55    #endregion
56
57    private EventWaitHandle trigger = new AutoResetEvent(false);
58
59    [TestMethod]
60    [DeploymentItem(@"SGAEngine.hl")]
61    public void SGAPerformanceTest() {
62      IEngine engine = (IEngine)XmlParser.Deserialize("SGAEngine.hl");
63      engine.Stopped += new EventHandler(engine_Stopped);
64      engine.Prepare();
65      engine.Start();
66      trigger.WaitOne();
67      TestContext.WriteLine("Runtime: {0}", engine.ExecutionTime.ToString());
68    }
69
70    private void engine_Stopped(object sender, EventArgs e) {
71      trigger.Set();
72    }
73  }
74}
Note: See TracBrowser for help on using the repository browser.