protected override void Build(FlowBuilder builder) { builder.WithDefaultFaultHandler <MyFaultHandler>(); builder.WithDefaultCancellationHandler <MyCancellationHandler>(); var inputFirst = builder.Activity <ReadIntActivity>("Read first number"); var inputSecond = builder.Activity <ReadIntActivity>("Read second number"); var first = Result <int> .Of(inputFirst); var second = Result <int> .Of(inputSecond); var condition = builder.Condition("If first number > second number"); condition.WithCondition(() => first.Get() > second.Get()); var outputWhenTrue = builder.Activity <WriteMessageActivity>("Output: first > second"); outputWhenTrue .Bind(x => x.Message) .To(() => $"{first.Get()} > {second.Get()}"); var outputWhenFalse = builder.Activity <WriteMessageActivity>("Output: first <= second"); outputWhenFalse .Bind(x => x.Message) .To(() => $"{first.Get()} <= {second.Get()}"); builder.WithInitialNode(inputFirst); inputFirst.ConnectTo(inputSecond); inputSecond.ConnectTo(condition); condition .ConnectTrueTo(outputWhenTrue) .ConnectFalseTo(outputWhenFalse); }
public void CheckFlowWithCondition() { // Arrange var b = new FlowBuilder(); var c = b.Condition(); var a = b.DummyActivity(); b.WithInitialNode(c); c.ConnectFalseTo(a).ConnectTrueTo(a); var e = b.DummyActivity(); var validator = new ReachabilityValidator(); // Act validator.Validate(b.CreateFlow()); var result = validator.Result; // Assert Assert.That(result.GetErrorsOf(c), Is.Empty); Assert.That(result.GetErrorsOf(a), Is.Empty); Assert.That(result.GetErrorsOf(e), Is.Not.Empty); }