ModuleController.Exit(Func<Boolean>) Method
Namespace: Firefly.Box.AdvancedAssembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
public void Exit(
Func<bool> condition
)
Public Sub Exit (
condition As Func(Of Boolean)
)
member Exit :
condition : Func<bool> -> unit
Parameters
- condition Func<Boolean>
- The timing in which the ModuleController will exit
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.
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);
enterRowEventHappened.ShouldBe(false);
}
[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);
bp.Run();
startEventHappened.ShouldBe(true);
enterRowEventHappened.ShouldBe(false);
}
[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);
}
}
}