src/GenFx.Wpf.Tests/ExecutionPanelViewModelTest.cs
/// <summary>
/// Tests that an exception is handled correctly when thrown from <see cref="GeneticAlgorithm.InitializeAsync"/>.
/// </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_StartExecutionAsync_ExceptionOnInitialize()
        {
            GeneticAlgorithm algorithm = CreateTestAlgorithm(true);
            ExecutionContext context = new ExecutionContext(algorithm)
            {
                ExecutionState = ExecutionState.Idle
            };
            using (ExecutionPanelViewModel viewModel = new ExecutionPanelViewModel(context))
            {
                algorithm.PopulationSeed = new TestPopulation2();
                await Assert.ThrowsAsync<ValidationException>(() => viewModel.StartExecutionAsync());
            }
            Assert.IsType<ValidationException>(context.AlgorithmException);
        }
[ Fact ] public async Task ExecutionPanelViewModel_StartExecutionAsync_ExceptionOnInitialize ( ) { GeneticAlgorithm algorithm = CreateTestAlgorithm ( true ) ; ExecutionContext context = new ExecutionContext ( algorithm ) { ExecutionState = ExecutionState . Idle } ; using ( ExecutionPanelViewModel viewModel = new ExecutionPanelViewModel ( context ) ) { algorithm . PopulationSeed = new TestPopulation2 ( ) ; await Assert . ThrowsAsync < ValidationException > ( ( ) => viewModel . StartExecutionAsync ( ) ) ; } Assert . IsType < ValidationException > ( context . AlgorithmException ) ; }
Tests that an exception is handled correctly when thrown from .
Tests that an exception is handled correctly when thrown from .
// Use a population that will cause a validation exception