Beispiel #1
0
        public void CreateNew_NoArgs_NewInstance()
        {
            RandomizationProvider.Current = Substitute.For <IRandomization>();
            RandomizationProvider.Current.GetInt(0, 3).Returns(-2);

            var old    = new IntegerChromosome(0, 3);
            var target = old.CreateNew() as IntegerChromosome;

            Assert.AreNotSame(old, target);
            Assert.AreEqual("11111111111111111111111111111110", target.ToString());

            var actual = target.ToInteger();

            Assert.AreEqual(-2, actual);
        }
        public void Integer()
        {
            var target = new IntegerChromosome(0, 10);

            target.Clone();
            target.CompareTo(new IntegerChromosome(0, 10));
            target.CreateNew();
            var x = target.Fitness;

            target.FlipGene(0);
            target.GenerateGene(0);
            target.GetGene(0);
            target.GetGenes();
            target.GetHashCode();
            var y = target.Length;

            target.ReplaceGene(0, new Gene(false));
            target.ReplaceGenes(0, new Gene[] { new Gene(false), new Gene(true) });
            target.Resize(20);
            target.ToInteger();
            target.ToString();
        }