Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Tests/PWRGOXCrossoverTest.cs @ 7634

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

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

File size: 2.2 KB
Line 
1using HeuristicLab.Core;
2using HeuristicLab.Encodings.IntegerVectorEncoding;
3using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition;
4using Microsoft.VisualStudio.TestTools.UnitTesting;
5
6namespace HeuristicLab.Encodings.ScheduleEncoding.Tests {
7
8
9  /// <summary>
10  ///This is a test class for PWRGOXCrossoverTest and is intended
11  ///to contain all PWRGOXCrossoverTest Unit Tests
12  ///</summary>
13  [TestClass()]
14  public class PWRGOXCrossoverTest {
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[] { 3 }, null);
69      PWREncoding parent1 = TestUtils.CreateTestPWR1();
70      PWREncoding parent2 = TestUtils.CreateTestPWR2();
71      PWREncoding expected = new PWREncoding();
72      expected.PermutationWithRepetition = new IntegerVector(new int[] { 1, 0, 1, 0, 2, 0, 1, 2, 2 });
73      PWREncoding actual;
74      actual = PWRGOXCrossover.Apply(random, parent1, parent2);
75      Assert.IsTrue(actual.Equals(expected));
76    }
77  }
78}
Note: See TracBrowser for help on using the repository browser.