src/GenFx.Tests/MetricTest.cs
/// <summary>
/// Tests that the object can be serialized and deserialized.
/// </summary>
Tests that the object can be serialized and deserialized.
Tests that the object can be serialized and deserialized .
[Fact]
        public void Metric_Serialization()
        {
            MockMetric metric = new MockMetric();
            PrivateObject privObj = new PrivateObject(metric, new PrivateType(typeof(Metric)));
            Dictionary<int, ObservableCollection<MetricResult>> popResults = (Dictionary<int, ObservableCollection<MetricResult>>)privObj.GetField("populationResults");
            ObservableCollection<MetricResult> metricResults = new ObservableCollection<MetricResult>
            {
                new MetricResult(1, 2, 3, metric)
            };
            popResults.Add(0, metricResults);
            MockMetric result = (MockMetric)SerializationHelper.TestSerialization(metric, new Type[0]);
            PrivateObject resultPrivObj = new PrivateObject(result, new PrivateType(typeof(Metric)));
            Dictionary<int, ObservableCollection<MetricResult>> resultPopResults = (Dictionary<int, ObservableCollection<MetricResult>>)resultPrivObj.GetField("populationResults");
            ObservableCollection<MetricResult> resultStatResults = resultPopResults[0];
            Assert.Equal(metricResults[0].GenerationIndex, resultStatResults[0].GenerationIndex);
            Assert.Equal(metricResults[0].PopulationIndex, resultStatResults[0].PopulationIndex);
            Assert.Equal(metricResults[0].ResultValue, resultStatResults[0].ResultValue);
            Assert.Same(result, resultStatResults[0].Metric);
        }
[ Fact ] public void Metric_Serialization ( ) { MockMetric metric = new MockMetric ( ) ; PrivateObject privObj = new PrivateObject ( metric , new PrivateType ( typeof ( Metric ) ) ) ; Dictionary < int , ObservableCollection < MetricResult > > popResults = ( Dictionary < int , ObservableCollection < MetricResult > > ) privObj . GetField ( " " ) ; ObservableCollection < MetricResult > metricResults = new ObservableCollection < MetricResult > { new MetricResult ( 1 , 2 , 3 , metric ) } ; popResults . Add ( 0 , metricResults ) ; MockMetric result = ( MockMetric ) SerializationHelper . TestSerialization ( metric , new Type [ 0 ] ) ; PrivateObject resultPrivObj = new PrivateObject ( result , new PrivateType ( typeof ( Metric ) ) ) ; Dictionary < int , ObservableCollection < MetricResult > > resultPopResults = ( Dictionary < int , ObservableCollection < MetricResult > > ) resultPrivObj . GetField ( " " ) ; ObservableCollection < MetricResult > resultStatResults = resultPopResults [ 0 ] ; Assert . Equal ( metricResults [ 0 ] . GenerationIndex , resultStatResults [ 0 ] . GenerationIndex ) ; Assert . Equal ( metricResults [ 0 ] . PopulationIndex , resultStatResults [ 0 ] . PopulationIndex ) ; Assert . Equal ( metricResults [ 0 ] . ResultValue , resultStatResults [ 0 ] . ResultValue ) ; Assert . Same ( result , resultStatResults [ 0 ] . Metric ) ; }
Tests that the object can be serialized and deserialized.
Tests that the object can be serialized and deserialized .