src/GenFx.Wpf.Tests/MetricsChartTest.cs
/// <summary>
/// Tests that the chart does not add a series for a metric that doesn't produce values convertible to double.
/// </summary>
Tests that the chart does not add a series for a metric that doesn't produce values convertible to double.
Tests that the chart does not add a series for a metric that doesn ' t produce values convertible to double .
[StaFact]
        public void MetricsChart_MetricWithNonDoubleResult()
        {
            TestPopulation population = new TestPopulation();
            TestAlgorithm algorithm = new TestAlgorithm();
            Metric metric1 = Mock.Of<Metric>();
            List<MetricResult> metric1Results = new List<MetricResult>
            {
                new MetricResult(0, 0, "foo", metric1),
                new MetricResult(0, 1, "bar", 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);
            MetricsChart chart = new MetricsChart
            {
                Algorithm = algorithm,
                Population = population
            };
            Assert.Single(chart.PlotModel.Series);
            Assert.Equal(metric2Results, (ICollection)((LineSeries)chart.PlotModel.Series[0]).ItemsSource);
        }
[ StaFact ] public void MetricsChart_MetricWithNonDoubleResult ( ) { TestPopulation population = new TestPopulation ( ) ; TestAlgorithm algorithm = new TestAlgorithm ( ) ; Metric metric1 = Mock . Of < Metric > ( ) ; List < MetricResult > metric1Results = new List < MetricResult > { new MetricResult ( 0 , 0 , " " , metric1 ) , new MetricResult ( 0 , 1 , " " , 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 ) ; MetricsChart chart = new MetricsChart { Algorithm = algorithm , Population = population } ; Assert . Single ( chart . PlotModel . Series ) ; Assert . Equal ( metric2Results , ( ICollection ) ( ( LineSeries ) chart . PlotModel . Series [ 0 ] ) . ItemsSource ) ; }
Tests that the chart does not add a series for a metric that doesn't produce values convertible to double.
Tests that the chart does not add a series for a metric that doesn ' t produce values convertible to double .