Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Tests/SinglePointCrossoverTest.cs @ 3376

Last change on this file since 3376 was 3376, checked in by swagner, 14 years ago

Moved interfaces and classes for deep cloning from HeuristicLab.Core to HeuristicLab.Common (#975).

File size: 3.3 KB
Line 
1using HeuristicLab.Encodings.BinaryVectorEncoding;
2using Microsoft.VisualStudio.TestTools.UnitTesting;
3using HeuristicLab.Common;
4using HeuristicLab.Core;
5using HeuristicLab.Data;
6using HeuristicLab.Parameters;
7
8namespace HeuristicLab.Encodings.BinaryVectorEncoding_33.Tests {
9
10
11  /// <summary>
12  ///This is a test class for SinglePointCrossoverTest and is intended
13  ///to contain all SinglePointCrossoverTest Unit Tests
14  ///</summary>
15  [TestClass()]
16  public class SinglePointCrossoverTest {
17
18
19    private TestContext testContextInstance;
20
21    /// <summary>
22    ///Gets or sets the test context which provides
23    ///information about and functionality for the current test run.
24    ///</summary>
25    public TestContext TestContext {
26      get {
27        return testContextInstance;
28      }
29      set {
30        testContextInstance = value;
31      }
32    }
33
34    #region Additional test attributes
35    //
36    //You can use the following additional attributes as you write your tests:
37    //
38    //Use ClassInitialize to run code before running the first test in the class
39    //[ClassInitialize()]
40    //public static void MyClassInitialize(TestContext testContext)
41    //{
42    //}
43    //
44    //Use ClassCleanup to run code after all tests in a class have run
45    //[ClassCleanup()]
46    //public static void MyClassCleanup()
47    //{
48    //}
49    //
50    //Use TestInitialize to run code before running each test
51    //[TestInitialize()]
52    //public void MyTestInitialize()
53    //{
54    //}
55    //
56    //Use TestCleanup to run code after each test has run
57    //[TestCleanup()]
58    //public void MyTestCleanup()
59    //{
60    //}
61    //
62    #endregion
63
64    /// <summary>
65    ///A test for Cross
66    ///</summary>
67    [TestMethod()]
68    [DeploymentItem("HeuristicLab.Encodings.BinaryVectorEncoding-3.3.dll")]
69    public void SinglePointCrossoverCrossTest() {
70      SinglePointCrossover_Accessor target = new SinglePointCrossover_Accessor(new PrivateObject(typeof(SinglePointCrossover)));
71      ItemArray<BinaryVector> parents;
72      TestRandom random = new TestRandom();
73      bool exceptionFired;
74      // The following test checks if there is an exception when there are more than 2 parents
75      random.Reset();
76      parents = new ItemArray<BinaryVector>(new BinaryVector[] { new BinaryVector(5), new BinaryVector(6), new BinaryVector(4) });
77      exceptionFired = false;
78      try {
79        BinaryVector actual;
80        actual = target.Cross(random, parents);
81      }
82      catch (System.ArgumentException) {
83        exceptionFired = true;
84      }
85      Assert.IsTrue(exceptionFired);
86      // The following test checks if there is an exception when there are less than 2 parents
87      random.Reset();
88      parents = new ItemArray<BinaryVector>(new BinaryVector[] { new BinaryVector(4) });
89      exceptionFired = false;
90      try {
91        BinaryVector actual;
92        actual = target.Cross(random, parents);
93      } catch (System.ArgumentException) {
94        exceptionFired = true;
95      }
96      Assert.IsTrue(exceptionFired);
97    }
98
99    /// <summary>
100    ///A test for SinglePointCrossover Constructor
101    ///</summary>
102    [TestMethod()]
103    public void SinglePointCrossoverConstructorTest() {
104      SinglePointCrossover target = new SinglePointCrossover();
105    }
106  }
107}
Note: See TracBrowser for help on using the repository browser.