Beispiel #1
0
        public void AllowNullAlleles()
        {
            var gene = AnyGene.Of((int?)null, () => null);

            Assert.Null(gene.Allele);
            for (var i = 0; i < 10; ++i)
            {
                Assert.Null(gene.NewInstance().Allele);
            }
        }
Beispiel #2
0
        public override void NewInstance()
        {
            Random random = new ContinuousRandom(0);
            var    gene   = AnyGene.Of(random.Next);

            for (var i = 0; i < 100; ++i)
            {
                var g = gene.NewInstance();
                Assert.Equal(i + 1, g.Allele);
            }
        }
Beispiel #3
0
        public override void IsValid()
        {
            var gene = AnyGene.Of(
                () => RandomRegistry.GetRandom().NextInt(1000),
                i => i < 100
                );

            for (var i = 0; i < 5000; ++i)
            {
                var g = gene.NewInstance();

                Assert.Equal(g.Allele < 100, g.IsValid);
                Assert.True(g.Allele < 1000);
                Assert.True(g.Allele >= 0);
            }
        }
Beispiel #4
0
 protected override Factory <AnyGene <int> > Factory()
 {
     return(() => AnyGene.Of(RandomRegistry.GetRandom().NextInt));
 }