コード例 #1
0
        public async Task SimpleFlowElementCanExecuteErrorShouldNotExecuteSecondStep()
        {
            var flow = new FlowBuilder()
                       .Add(
                FlowElementBuilder
                .New()
                .CanExecute(async(i, _) => CanExecuteResult.Error("error"))
                .OnExecute(async(i, _) => throw new Exception("Should not execute step 1"))
                .Build()
                ,
                FlowElementBuilder
                .New()
                .CanExecute(async(i, _) => CanExecuteResult.Continue)
                .OnExecute(async(i, _) => throw new Exception("Should not execute step 2"))
                .Build()
                )
                       .Build();

            var flowResult = await flow.RunAsync(4);

            flowResult
            .Should()
            .BeOfType <FlowErrorResult>()
            .Which.ErrorObject
            .Should().Be("error");
        }
コード例 #2
0
    public CanExecuteResult CanExecute()
    {
        var result = new CanExecuteResult {
            CanExecute = true
        };
        var messages = new List <string>();

        if (SomeCondition)
        {
            result.CanExecute = false;
            messages.Add("Some reason");
        }

        if (AnotherCondition)
        {
            result.CanExecute = false;
            messages.Add("Another reason");
        }

        result.Messages = messages;

        return(result);
    }