public void TreeEntityBase_CopyToNullEntity() { MockGeneticAlgorithm algorithm = new MockGeneticAlgorithm { PopulationSeed = new MockPopulation(), SelectionOperator = new MockSelectionOperator(), FitnessEvaluator = new MockFitnessEvaluator(), GeneticEntitySeed = new TestTreeEntity() }; TestTreeEntity entity = new TestTreeEntity(); entity.Initialize(algorithm); Assert.Throws <ArgumentNullException>(() => entity.CopyTo(null)); }
public void TreeEntityBase_CopyTo() { MockGeneticAlgorithm algorithm = new MockGeneticAlgorithm { PopulationSeed = new MockPopulation(), SelectionOperator = new MockSelectionOperator(), FitnessEvaluator = new MockFitnessEvaluator(), GeneticEntitySeed = new TestTreeEntity() }; TestTreeEntity entity = new TestTreeEntity(); entity.Initialize(algorithm); entity.Age = 10; entity.SetRootNode(new TreeNode()); TestTreeEntity newEntity = new TestTreeEntity(); newEntity.Initialize(algorithm); entity.CopyTo(newEntity); Assert.Equal(entity.Age, newEntity.Age); Assert.NotNull(entity.RootNode); }