Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Tests/JSMJOXCrossoverTest.cs @ 6409

Last change on this file since 6409 was 6406, checked in by jhelm, 14 years ago

#1329: Applied suggestions from codereview. Added unit-tests. Renamed encoding-project.

File size: 2.4 KB
RevLine 
[6406]1using HeuristicLab.Core;
2using HeuristicLab.Encodings.PermutationEncoding;
3using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix;
4using Microsoft.VisualStudio.TestTools.UnitTesting;
5
6namespace HeuristicLab.Encodings.ScheduleEncoding.Tests {
7
8
9  /// <summary>
10  ///This is a test class for JSMJOXCrossoverTest and is intended
11  ///to contain all JSMJOXCrossoverTest Unit Tests
12  ///</summary>
13  [TestClass()]
14  public class JSMJOXCrossoverTest {
15
16
17    private TestContext testContextInstance;
18
19    /// <summary>
20    ///Gets or sets the test context which provides
21    ///information about and functionality for the current test run.
22    ///</summary>
23    public TestContext TestContext {
24      get {
25        return testContextInstance;
26      }
27      set {
28        testContextInstance = value;
29      }
30    }
31
32    #region Additional test attributes
33    //
34    //You can use the following additional attributes as you write your tests:
35    //
36    //Use ClassInitialize to run code before running the first test in the class
37    //[ClassInitialize()]
38    //public static void MyClassInitialize(TestContext testContext)
39    //{
40    //}
41    //
42    //Use ClassCleanup to run code after all tests in a class have run
43    //[ClassCleanup()]
44    //public static void MyClassCleanup()
45    //{
46    //}
47    //
48    //Use TestInitialize to run code before running each test
49    //[TestInitialize()]
50    //public void MyTestInitialize()
51    //{
52    //}
53    //
54    //Use TestCleanup to run code after each test has run
55    //[TestCleanup()]
56    //public void MyTestCleanup()
57    //{
58    //}
59    //
60    #endregion
61
62
63    /// <summary>
64    ///A test for Apply
65    ///</summary>
66    [TestMethod()]
67    public void ApplyTest() {
68      IRandom random = new TestRandom(new int[] { 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1 }, null);
69      JSMEncoding p1 = TestUtils.CreateTestJSM1();
70      JSMEncoding p2 = TestUtils.CreateTestJSM2();
71      JSMEncoding expected = new JSMEncoding();
72      ItemList<Permutation> jsm = new ItemList<Permutation>();
73      for (int i = 0; i < 6; i++) {
74        jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 5, 4, 3, 0, 1, 2 }));
75      }
76      expected.JobSequenceMatrix = jsm;
77
78      JSMEncoding actual;
79      actual = JSMJOXCrossover.Apply(random, p1, p2);
80
81      Assert.IsTrue(expected.Equals(actual));
82    }
83  }
84}
Note: See TracBrowser for help on using the repository browser.