Example #1
0
    // After the initialization, the sum of all values for the keys must to be equal to DNACode.sumatoryGenValues
    private void Test_initialize()
    {
        DNACode dna = new DNACode().initialize();

        int total_quantity = dna.calculateTotalQuantity();
        int correctValue   = dna.getSumatoryGenValues();

        Assert.That(total_quantity, Is.EqualTo(correctValue));
    }
Example #2
0
    private void Test_mutate()
    {
        int N = 100;

        for (int i = 0; i < N; i++)
        {
            DNACode dna = new DNACode().initialize();

            dna.mutate();
            int total_quantity = dna.calculateTotalQuantity();
            int correctValue   = dna.getSumatoryGenValues();

            Assert.That(total_quantity, Is.EqualTo(correctValue));
        }
    }
Example #3
0
    private void Test_combine()
    {
        int N = 100;

        for (int i = 0; i < N; i++)
        {
            DNACode[] parents = new DNACode[2];
            parents[0] = new DNACode().initialize();
            parents[1] = new DNACode().initialize();

            DNACode new_dna        = DNACode.combine(parents);
            int     total_quantity = new_dna.calculateTotalQuantity();
            int     correctValue   = new_dna.getSumatoryGenValues();

            Assert.That(total_quantity, Is.EqualTo(correctValue));
        }
    }