ExitTiming Enumeration
Used to determine the timing in which a task is exited.
Namespace: Firefly.BoxAssembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
Public Enumeration ExitTiming
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.
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);
}
}
}
BeforeRow | 0 |
After the row is loaded, but before the EnterRow event.
|
AfterRow | 1 |
After the row is saved to the Database
|
AsSoonAsPossible | 2 |
As soon as possible
|