src/GenFx.Wpf.Tests/MetricsChartTest.cs
/// <summary>
/// Tests that the chart refreshes when the algorithm changes from a previous algorithm.
/// </summary>
Tests that the chart refreshes when the algorithm changes from a previous algorithm.
Tests that the chart refreshes when the algorithm changes from a previous algorithm .
[StaFact]
        public void MetricsChart_OnAlgorithmChanged_FromOtherAlgorithm()
        {
            TestPopulation population = new TestPopulation();
            TestAlgorithm algorithm = new TestAlgorithm();
            Metric metric1 = Mock.Of<Metric>();
            List<MetricResult> metric1Results = new List<MetricResult>
            {
                new MetricResult(0, 0, 1, metric1),
                new MetricResult(0, 1, 2, metric1)
            };
            metric1.GetResults(0).AddRange(metric1Results);
            Metric metric2 = Mock.Of<Metric>();
            List<MetricResult> metric2Results = new List<MetricResult>
            {
                new MetricResult(0, 0, 3, metric1),
                new MetricResult(0, 1, 4, metric1)
            };
            metric2.GetResults(0).AddRange(metric2Results);
            algorithm.Metrics.Add(metric1);
            algorithm.Metrics.Add(metric2);
            VerifyChartRefresh(chart =>
            {
                chart.Population = population;
                chart.Algorithm = new TestAlgorithm();
            }, chart =>
            {
                chart.Algorithm = algorithm;
            }, (metric, series) =>
            {
                if (metric == metric1)
                {
                    Assert.Equal(metric1Results, (ICollection)series.ItemsSource);
                }
                else if (metric == metric2)
                {
                    Assert.Equal(metric2Results, (ICollection)series.ItemsSource);
                }
            });
        }
[ StaFact ] public void MetricsChart_OnAlgorithmChanged_FromOtherAlgorithm ( ) { TestPopulation population = new TestPopulation ( ) ; TestAlgorithm algorithm = new TestAlgorithm ( ) ; Metric metric1 = Mock . Of < Metric > ( ) ; List < MetricResult > metric1Results = new List < MetricResult > { new MetricResult ( 0 , 0 , 1 , metric1 ) , new MetricResult ( 0 , 1 , 2 , metric1 ) } ; metric1 . GetResults ( 0 ) . AddRange ( metric1Results ) ; Metric metric2 = Mock . Of < Metric > ( ) ; List < MetricResult > metric2Results = new List < MetricResult > { new MetricResult ( 0 , 0 , 3 , metric1 ) , new MetricResult ( 0 , 1 , 4 , metric1 ) } ; metric2 . GetResults ( 0 ) . AddRange ( metric2Results ) ; algorithm . Metrics . Add ( metric1 ) ; algorithm . Metrics . Add ( metric2 ) ; VerifyChartRefresh ( chart => { chart . Population = population ; chart . Algorithm = new TestAlgorithm ( ) ; } , chart => { chart . Algorithm = algorithm ; } , ( metric , series ) => { if ( metric == metric1 ) { Assert . Equal ( metric1Results , ( ICollection ) series . ItemsSource ) ; } else if ( metric == metric2 ) { Assert . Equal ( metric2Results , ( ICollection ) series . ItemsSource ) ; } } ) ; }
Tests that the chart refreshes when the algorithm changes from a previous algorithm.
Tests that the chart refreshes when the algorithm changes from a previous algorithm .