src/GenFx.Tests/GeneticEntityTest.cs
/// <summary>
/// Tests that the CopyTo method works correctly.
/// </summary>
Tests that the CopyTo method works correctly.
Tests that the CopyTo method works correctly .
[Fact]
        public void Entity_CopyTo()
        {
            GeneticAlgorithm algorithm = new MockGeneticAlgorithm
            {
                PopulationSeed = new MockPopulation(),
                SelectionOperator = new MockSelectionOperator(),
                FitnessEvaluator = new MockFitnessEvaluator(),
                GeneticEntitySeed = new MockEntity()
            };
            MockEntity entity = new MockEntity();
            entity.Initialize(algorithm);
            entity.Age = 10;
            entity.ScaledFitnessValue = 10;
            PrivateObject accessor = new PrivateObject(entity, new PrivateType(typeof(GeneticEntity)));
            accessor.SetField("rawFitnessValue", 123);
            MockEntity newEntity = new MockEntity();
            newEntity.Initialize(algorithm);
            entity.CopyTo(newEntity);
            Assert.Equal(entity.Age, newEntity.Age);
            Assert.Equal(entity.RawFitnessValue, newEntity.RawFitnessValue);
            Assert.Equal(entity.ScaledFitnessValue, newEntity.ScaledFitnessValue);
        }
[ Fact ] public void Entity_CopyTo ( ) { GeneticAlgorithm algorithm = new MockGeneticAlgorithm { PopulationSeed = new MockPopulation ( ) , SelectionOperator = new MockSelectionOperator ( ) , FitnessEvaluator = new MockFitnessEvaluator ( ) , GeneticEntitySeed = new MockEntity ( ) } ; MockEntity entity = new MockEntity ( ) ; entity . Initialize ( algorithm ) ; entity . Age = 10 ; entity . ScaledFitnessValue = 10 ; PrivateObject accessor = new PrivateObject ( entity , new PrivateType ( typeof ( GeneticEntity ) ) ) ; accessor . SetField ( " " , 123 ) ; MockEntity newEntity = new MockEntity ( ) ; newEntity . Initialize ( algorithm ) ; entity . CopyTo ( newEntity ) ; Assert . Equal ( entity . Age , newEntity . Age ) ; Assert . Equal ( entity . RawFitnessValue , newEntity . RawFitnessValue ) ; Assert . Equal ( entity . ScaledFitnessValue , newEntity . ScaledFitnessValue ) ; }
Tests that the CopyTo method works correctly.
Tests that the CopyTo method works correctly .