UIControllerExit(ExitTiming) Method

Instructs the UIController to exit.

Definition

Namespace: Firefly.Box
Assembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
C#
public void Exit(
	ExitTiming timing
)

Parameters

timing  ExitTiming
The timing in which the UIController will exit

Example

This example demonstrates the usage of Exit
This example is in the form of Unit Tests. It references the NUnit framework. This framework can be downloaded from www.NUnit.org. For more information about unit testing visit: www.NUnit.org.
C#
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Firefly.Box;
using Firefly.Box.Testing;

namespace TestFirefly.Box.Documentation
{
    [TestFixture]
    public class Exit
    {
        [Test]
        public void UsingExitWithoutParameters()
        {
            var bp = new BusinessProcess();
            int cycles = 0;
            bp.LeaveRow += () =>
                             {
                                 cycles++;
                                 if (cycles > 5)
                                     bp.Exit();
                             };
            bp.Run();
            cycles.ShouldBe(6);
        }
        [Test]
        public void UsingExitBeforeTheTaskRuns()
        {
            var bp = new BusinessProcess();
            bool startEventHappened = false;
            bool enterRowEventHappened = false;
            bp.Start += () => startEventHappened = true;
            bp.EnterRow += () => enterRowEventHappened = true;
            bp.Exit();
            bp.Run();
            startEventHappened.ShouldBe(true);//The start event happens regardless of the exit command, 
            //as the exit command is evaluated at the row level.
            enterRowEventHappened.ShouldBe(false);//The enter row event didn't happen, because the task was instructed to exit.
        }
        [Test]
        public void UsingExitWithBeforeEnterRowTiming()
        {
            var bp = new BusinessProcess();
            bool startEventHappened = false;
            bool enterRowEventHappened = false;
            bp.Start += () => startEventHappened = true;
            bp.EnterRow += () => enterRowEventHappened = true;
            bp.Exit(ExitTiming.BeforeRow); //The default value, acts the same as without any parameters
            bp.Run();
            startEventHappened.ShouldBe(true);//The start event happens regardless of the exit command, 
            //as the exit command is evaluated at the row level.
            enterRowEventHappened.ShouldBe(false);//The enter row event didn't happen, because the task was instructed to exit.
        }
        [Test]
        public void UsingExitWithAflterLeaveRowTiming()
        {
            var bp = new BusinessProcess();
            bool leaveRowHappened = false;
            bp.LeaveRow += () => leaveRowHappened = true;
            bp.Exit(ExitTiming.AfterRow);
            bp.Run();
            leaveRowHappened.ShouldBe(true);
        }
        [Test]
        public void UsingExitWithAflterLeaveRowTimingAndACondition()
        {
            var bp = new BusinessProcess();
            int cycles = 0;
            bp.LeaveRow += () =>
                {
                    cycles++;
                };
            bp.Exit(ExitTiming.AfterRow, () => cycles > 5);
            bp.Run();
            cycles.ShouldBe(6);
        }
    }
}

See Also