Exemple #1
0
        public void TwoMatchesCanNotBeDefined()
        {
            var tree = GenomeTest.BuildSimpleTestTreeWithAndRoot();

            tree.AddParameterReplacementDefinition("a", 42, "dummy", 1337);
            Assert.Throws <InvalidOperationException>(() => tree.AddParameterReplacementDefinition("a", 42, "dummy2", 1338));
        }
Exemple #2
0
        public void IgnoredParametersAreRemoved()
        {
            var tree = GenomeTest.BuildSimpleTestTreeWithAndRoot();

            tree.AddIgnoredParameter("a");
            this._genome.SetGene("a", new Allele <int>(42));
            this._genome.SetGene("b", new Allele <int>(0));
            this._genome.SetGene("c", new Allele <int>(0));
            var filteredParameters = this._genome.GetFilteredGenes(tree);

            Assert.False(filteredParameters.ContainsKey("a"), "<a> was not removed, even though it was ignored.");
            Assert.True(filteredParameters.ContainsKey("b"), "<b> was removed even though it was not filtered");
        }
Exemple #3
0
        public void ParameterReplacementDoesNotRemoveIfValueDoesNotMatch()
        {
            var tree = GenomeTest.BuildSimpleTestTreeWithAndRoot();

            tree.AddParameterReplacementDefinition("a", 42, "dummy", 1337);
            this._genome.SetGene("a", new Allele <int>(0815));
            this._genome.SetGene("b", new Allele <int>(0));
            this._genome.SetGene("c", new Allele <int>(0));
            var filteredParameters = this._genome.GetFilteredGenes(tree);

            Assert.True(filteredParameters.ContainsKey("a"), "FilterIndicator is not matched, but <a> was removed from parameters.");
            Assert.False(filteredParameters.ContainsKey("dummy"), "<dummy> was inserted even though indicator value is not matched.");
        }
Exemple #4
0
        public void GetFilteredGenesUsesCorrectValues()
        {
            var parameterTree = GenomeTest.BuildSimpleTestTreeWithAndRoot();

            this._genome.SetGene("a", new Allele <int>(0));
            this._genome.SetGene("b", new Allele <int>(1));
            this._genome.SetGene("c", new Allele <int>(2));

            var filteredGenes = this._genome.GetFilteredGenes(parameterTree);

            Assert.Equal(0, filteredGenes["a"].GetValue());
            Assert.Equal(1, filteredGenes["b"].GetValue());
            Assert.Equal(2, filteredGenes["c"].GetValue());
        }
Exemple #5
0
        public void ParameterReplacementRemovesIgnoredParameterIfValueDoesNotMatch()
        {
            var tree = GenomeTest.BuildSimpleTestTreeWithAndRoot();

            tree.AddParameterReplacementDefinition("a", 42, "dummy", 1337, true);
            tree.AddParameterReplacementDefinition("a", 43, "dummy", 1338);
            this._genome.SetGene("a", new Allele <int>(0815));
            this._genome.SetGene("b", new Allele <int>(0));
            this._genome.SetGene("c", new Allele <int>(0));
            var filteredParameters = this._genome.GetFilteredGenes(tree);

            Assert.False(
                filteredParameters.ContainsKey("a"),
                "<a> was not removed, even though it should be added to the set of ignored parameters.");
            Assert.False(filteredParameters.ContainsKey("dummy"), "<dummy> was inserted even though indicator value is not matched.");
        }
Exemple #6
0
        public void ParameterReplacementTriggeredIfValueMatches()
        {
            var tree = GenomeTest.BuildSimpleTestTreeWithAndRoot();

            tree.AddParameterReplacementDefinition("a", 42, "dummy", 1337);
            tree.AddParameterReplacementDefinition("a", 43, "dummy", 1338);
            this._genome.SetGene("a", new Allele <int>(42));
            this._genome.SetGene("b", new Allele <int>(0));
            this._genome.SetGene("c", new Allele <int>(0));
            var filteredParameters = this._genome.GetFilteredGenes(tree);

            Assert.False(filteredParameters.ContainsKey("a"), "<a> was not removed, even though the indicator value was matched.");
            Assert.True(filteredParameters.ContainsKey("dummy"), "<dummy> should have been inserted into the set of parameters.");

            // Replacement <a, 42, dummy, 1337> should have been triggered.
            Assert.Equal(1337, filteredParameters["dummy"].GetValue());
        }
Exemple #7
0
        public void GetFilteredGenesIgnoreAndNodes()
        {
            var parameterTree = GenomeTest.BuildSimpleTestTreeWithAndRoot();

            this._genome.SetGene("a", new Allele <int>(0));
            this._genome.SetGene("b", new Allele <int>(1));
            this._genome.SetGene("c", new Allele <int>(2));

            var filteredGenes         = this._genome.GetFilteredGenes(parameterTree);
            var expectedFilteredGenes = new List <string> {
                "a", "b", "c"
            };

            Assert.True(
                TestUtils.SetsAreEquivalent(filteredGenes.Keys, expectedFilteredGenes),
                $"Filtered genes should be {TestUtils.PrintList(expectedFilteredGenes)}, but are {TestUtils.PrintList(filteredGenes.Keys)}.");
        }
Exemple #8
0
        public void UndefinedIndicatorNameCausesException()
        {
            var tree = GenomeTest.BuildSimpleTestTreeWithAndRoot();

            Assert.Throws <ArgumentException>(() => tree.AddParameterReplacementDefinition("unknown", false, "dummy", 42));
        }