src/GenFx.Wpf.Tests/ExecutionPanelViewModelTest.cs
/// <summary>
/// Tests that the <see cref="ExecutionPanelViewModel.Dispose"/> method works correctly.
/// </summary>
Tests that the  method works correctly.
Tests that the method works correctly .
[Fact]
        public void ExecutionPanelViewModel_Dispose()
        {
            GeneticAlgorithm algorithm = CreateTestAlgorithm();
            ExecutionContext context = new ExecutionContext(algorithm);
            ExecutionPanelViewModel viewModel = new ExecutionPanelViewModel(context);
            context.ExecutionState = ExecutionState.Running;
            viewModel.Dispose();
            PrivateObject algorithmAccessor = new PrivateObject(algorithm, new PrivateType(typeof(GeneticAlgorithm)));
            algorithmAccessor.Invoke("OnAlgorithmCompleted");
            Assert.Equal(ExecutionState.Running, context.ExecutionState);
            context.ExecutionState = ExecutionState.PausePending;
            EnvironmentFitnessEvaluatedEventArgs eventArgs = new EnvironmentFitnessEvaluatedEventArgs(new GeneticEnvironment(algorithm), 0);
            algorithmAccessor.Invoke("OnFitnessEvaluated", eventArgs);
            Assert.False(eventArgs.Cancel);
        }
[ Fact ] public void ExecutionPanelViewModel_Dispose ( ) { GeneticAlgorithm algorithm = CreateTestAlgorithm ( ) ; ExecutionContext context = new ExecutionContext ( algorithm ) ; ExecutionPanelViewModel viewModel = new ExecutionPanelViewModel ( context ) ; context . ExecutionState = ExecutionState . Running ; viewModel . Dispose ( ) ; PrivateObject algorithmAccessor = new PrivateObject ( algorithm , new PrivateType ( typeof ( GeneticAlgorithm ) ) ) ; algorithmAccessor . Invoke ( " " ) ; Assert . Equal ( ExecutionState . Running , context . ExecutionState ) ; context . ExecutionState = ExecutionState . PausePending ; EnvironmentFitnessEvaluatedEventArgs eventArgs = new EnvironmentFitnessEvaluatedEventArgs ( new GeneticEnvironment ( algorithm ) , 0 ) ; algorithmAccessor . Invoke ( " " , eventArgs ) ; Assert . False ( eventArgs . Cancel ) ; }
Tests that the  method works correctly.
Tests that the method works correctly .
// Verify the ExecutionState is not reset when the genetic algorithm completes. // Verify the view model has unsubscribed from the FitnessEvaluated event.