src/GenFx.Wpf.Tests/ExecutionPanelViewModelTest.cs
/// <summary>
/// Tests that an exception is handled correctly when thrown from <see cref="GeneticAlgorithm.StepAsync"/>.
/// </summary>
Tests that an exception is handled correctly when thrown from .
Tests that an exception is handled correctly when thrown from .
[Fact]
        public async Task ExecutionPanelViewModel_StepExecutionAsync_ExceptionOnRun()
        {
            GeneticAlgorithm algorithm = CreateTestAlgorithm(true);
            ExecutionContext context = new ExecutionContext(algorithm)
            {
                ExecutionState = ExecutionState.Idle
            };
            using (ExecutionPanelViewModel viewModel = new ExecutionPanelViewModel(context))
            {
                algorithm.Terminator = new TestTerminator2();
                await Assert.ThrowsAsync<NotSupportedException>(() => viewModel.StepExecutionAsync());
            }
            Assert.IsType<NotSupportedException>(context.AlgorithmException);
        }
[ Fact ] public async Task ExecutionPanelViewModel_StepExecutionAsync_ExceptionOnRun ( ) { GeneticAlgorithm algorithm = CreateTestAlgorithm ( true ) ; ExecutionContext context = new ExecutionContext ( algorithm ) { ExecutionState = ExecutionState . Idle } ; using ( ExecutionPanelViewModel viewModel = new ExecutionPanelViewModel ( context ) ) { algorithm . Terminator = new TestTerminator2 ( ) ; await Assert . ThrowsAsync < NotSupportedException > ( ( ) => viewModel . StepExecutionAsync ( ) ) ; } Assert . IsType < NotSupportedException > ( context . AlgorithmException ) ; }
Tests that an exception is handled correctly when thrown from .
Tests that an exception is handled correctly when thrown from .
// Use a terminator that will cause an exception