akarpov89 / MicroFlow

Lightweight workflow engine
http://akarpov89.github.io/MicroFlow/
MIT License
156 stars 48 forks source link

If-ElseIf-Else conditon problem #8

Closed pnesterov closed 8 years ago

pnesterov commented 8 years ago

Hi, Andrey!

Looks like i've found a bug in If-ElseIf-Else conditon. If i define this condition with at least one ElseIf statement it's ok

var node = builder
    .If("Condition1", () => boolExpr1).Then(node1)
    .ElseIf("Condition2", () => boolExpr2).Then(node2)
    .Else(node3);  

but if i don't use ElseIf statement, node builder returns null:

var node = builder
    .If("Condition", () => boolExpr).Then(node1)
    .Else(node2);  

Best regards, Pavel

akarpov89 commented 8 years ago

Hi Pavel!

Thanks for pointing this out. I'll fix the issue and publish new version this evening. This line https://github.com/akarpov89/MicroFlow/blob/master/src/FlowNodes/IfThenElseExtension.cs#L67 misses null-coalescing InitialConditionNode ?? myConditionNode like it's done in ElseIf method.

Best regards, Andrey