src/GenFx.Tests/GeneticComponentExtensionsTest.cs
/// <summary>
/// Tests that the <see cref="GeneticComponentExtensions.CreateNewAndInitialize"/> works correctly.
/// </summary>
Tests that the  works correctly.
Tests that the works correctly .
[Fact]
        public void GeneticComponentExtensions_CreateNewAndInitialize()
        {
            TestComponent component = new TestComponent();
            component.MyProperty = 5;
            TestComponent newComponent = (TestComponent)GeneticComponentExtensions.CreateNewAndInitialize(component);
            Assert.NotSame(component, newComponent);
            Assert.Equal(component.MyProperty, newComponent.MyProperty);
            TestComponentWithAlgorithm componentWithAlg = new TestComponentWithAlgorithm();
            MockGeneticAlgorithm algorithm = new MockGeneticAlgorithm();
            componentWithAlg.Initialize(algorithm);
            TestComponentWithAlgorithm newComponentWithAlg = (TestComponentWithAlgorithm)GeneticComponentExtensions.CreateNewAndInitialize(componentWithAlg);
            Assert.NotSame(componentWithAlg, newComponentWithAlg);
            Assert.Same(componentWithAlg.Algorithm, newComponentWithAlg.Algorithm);
            Assert.True(componentWithAlg.InitializeCalled);
        }
[ Fact ] public void GeneticComponentExtensions_CreateNewAndInitialize ( ) { TestComponent component = new TestComponent ( ) ; component . MyProperty = 5 ; TestComponent newComponent = ( TestComponent ) GeneticComponentExtensions . CreateNewAndInitialize ( component ) ; Assert . NotSame ( component , newComponent ) ; Assert . Equal ( component . MyProperty , newComponent . MyProperty ) ; TestComponentWithAlgorithm componentWithAlg = new TestComponentWithAlgorithm ( ) ; MockGeneticAlgorithm algorithm = new MockGeneticAlgorithm ( ) ; componentWithAlg . Initialize ( algorithm ) ; TestComponentWithAlgorithm newComponentWithAlg = ( TestComponentWithAlgorithm ) GeneticComponentExtensions . CreateNewAndInitialize ( componentWithAlg ) ; Assert . NotSame ( componentWithAlg , newComponentWithAlg ) ; Assert . Same ( componentWithAlg . Algorithm , newComponentWithAlg . Algorithm ) ; Assert . True ( componentWithAlg . InitializeCalled ) ; }
Tests that the  works correctly.
Tests that the works correctly .