Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Tests/JSMShiftChangeManipulatorTest.cs @ 8970

Last change on this file since 8970 was 6406, checked in by jhelm, 13 years ago

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

File size: 2.4 KB
Line 
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 JSMShiftChangeManipulatorTest and is intended
11  ///to contain all JSMShiftChangeManipulatorTest Unit Tests
12  ///</summary>
13  [TestClass()]
14  public class JSMShiftChangeManipulatorTest {
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[] { 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 }, null);
69      JSMEncoding individual = TestUtils.CreateTestJSM1();
70      JSMShiftChangeManipulator.Apply(random, individual);
71      JSMEncoding expected = new JSMEncoding();
72      ItemList<Permutation> jsm = new ItemList<Permutation>();
73      for (int i = 0; i < 3; i++) {
74        jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 0, 1, 3, 2, 4, 5 }));
75        jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 0, 1, 3, 4, 2, 5 }));
76      }
77      expected.JobSequenceMatrix = jsm;
78
79      Assert.IsTrue(individual.Equals(expected));
80    }
81  }
82}
Note: See TracBrowser for help on using the repository browser.