src/GenFx.Tests/PopulationTest.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 Population_Serialization()
        {
            MockPopulation population = new MockPopulation
            {
                MinimumPopulationSize = 10,
                Index = 3,
            };
            population.Entities.Add(new MockEntity());
            PrivateObject privObj = new PrivateObject(population, new PrivateType(typeof(Population)));
            privObj.SetField("rawMean", (double)1);
            privObj.SetField("rawStandardDeviation", (double)2);
            privObj.SetField("rawMax", (double)3);
            privObj.SetField("rawMin", (double)4);
            MockPopulation result = (MockPopulation)SerializationHelper.TestSerialization(population, new Type[]
            {
                typeof(MockEntity)
            });
            PrivateObject resultPrivObj = new PrivateObject(result, new PrivateType(typeof(Population)));
            Assert.Equal(population.MinimumPopulationSize, result.MinimumPopulationSize);
            Assert.Equal(population.Index, result.Index);
            Assert.IsType<MockEntity>(result.Entities[0]);
            Assert.Equal((double)1, resultPrivObj.GetField("rawMean"));
            Assert.Equal((double)2, resultPrivObj.GetField("rawStandardDeviation"));
            Assert.Equal((double)3, resultPrivObj.GetField("rawMax"));
            Assert.Equal((double)4, resultPrivObj.GetField("rawMin"));
        }
[ Fact ] public void Population_Serialization ( ) { MockPopulation population = new MockPopulation { MinimumPopulationSize = 10 , Index = 3 , } ; population . Entities . Add ( new MockEntity ( ) ) ; PrivateObject privObj = new PrivateObject ( population , new PrivateType ( typeof ( Population ) ) ) ; privObj . SetField ( " " , ( double ) 1 ) ; privObj . SetField ( " " , ( double ) 2 ) ; privObj . SetField ( " " , ( double ) 3 ) ; privObj . SetField ( " " , ( double ) 4 ) ; MockPopulation result = ( MockPopulation ) SerializationHelper . TestSerialization ( population , new Type [ ] { typeof ( MockEntity ) } ) ; PrivateObject resultPrivObj = new PrivateObject ( result , new PrivateType ( typeof ( Population ) ) ) ; Assert . Equal ( population . MinimumPopulationSize , result . MinimumPopulationSize ) ; Assert . Equal ( population . Index , result . Index ) ; Assert . IsType < MockEntity > ( result . Entities [ 0 ] ) ; Assert . Equal ( ( double ) 1 , resultPrivObj . GetField ( " " ) ) ; Assert . Equal ( ( double ) 2 , resultPrivObj . GetField ( " " ) ) ; Assert . Equal ( ( double ) 3 , resultPrivObj . GetField ( " " ) ) ; Assert . Equal ( ( double ) 4 , resultPrivObj . GetField ( " " ) ) ; }
Tests that the object can be serialized and deserialized.
Tests that the object can be serialized and deserialized .