Skip to content

Commit

Permalink
stupid mistakes, so needed to rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Sulwer committed Jun 22, 2024
1 parent 31c576c commit 57356f3
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion demo/DemoApp/Demos/Basic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public async Task Run(CancellationToken ct = default)
outcome = true;
});

resultList.OnFail((eventName) => {
resultList.OnFail(() => {
outcome = false;
});

Expand Down
4 changes: 2 additions & 2 deletions demo/DemoApp/Demos/BasicWithCustomTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ public async Task Run(CancellationToken ct = default)
ruleResultTree.OnSuccess((eventName) => {
Console.WriteLine($"Result '{eventName}' is as expected.");
});
ruleResultTree.OnFail((eventName) => {
ruleResultTree.OnFail(() => {
Console.WriteLine($"Test outcome: false");
});

var actionRuleResult = await bre.ExecuteActionWorkflowAsync("Test Workflow Rule 1", "Test Rule", [string1], ct);
actionRuleResult.Results.OnSuccess((eventName) => {
Console.WriteLine($"Result '{eventName}' is as expected.");
});
actionRuleResult.Results.OnFail((eventName) => {
actionRuleResult.Results.OnFail(() => {
Console.WriteLine($"Test outcome: false");
});
}
Expand Down
2 changes: 1 addition & 1 deletion demo/DemoApp/Demos/EF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public async Task Run(CancellationToken ct = default)
discountOffered = $"Discount offered is {eventName} % over MRP.";
});

resultList.OnFail((eventName) => {
resultList.OnFail(() => {
discountOffered = "The user is not eligible for any discount.";
});

Expand Down
2 changes: 1 addition & 1 deletion demo/DemoApp/Demos/JSON.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task Run(CancellationToken ct = default)
discountOffered = $"Discount offered is {eventName} % over MRP.";
});

resultList.OnFail((eventName) => {
resultList.OnFail(() => {
discountOffered = "The user is not eligible for any discount.";
});

Expand Down
2 changes: 1 addition & 1 deletion demo/DemoApp/Demos/NestedInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task Run(CancellationToken ct = default)

resultList.OnSuccess((eventName) => {
Console.WriteLine($"{workflow.WorkflowName} evaluation resulted in success - {eventName}");
}).OnFail((eventName) => {
}).OnFail(() => {
Console.WriteLine($"{workflow.WorkflowName} evaluation resulted in failure");
});
}
Expand Down
12 changes: 4 additions & 8 deletions src/RulesEngine/Extensions/ListofRuleResultTreeExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace RulesEngine.Extensions
public static class ListofRuleResultTreeExtension
{
public delegate void OnSuccessFunc(string eventName);
public delegate void OnFailureFunc(string eventName);
public delegate void OnFailureFunc();


/// <summary>
Expand Down Expand Up @@ -40,13 +40,9 @@ public static List<RuleResultTree> OnSuccess(this List<RuleResultTree> ruleResul
/// <returns></returns>
public static List<RuleResultTree> OnFail(this List<RuleResultTree> ruleResultTrees, OnFailureFunc onFailureFunc)
{
var allFailure = ruleResultTrees.FirstOrDefault(ruleResult => ruleResult.IsSuccess == false);
if (allFailure != null)
{
var eventName = allFailure.Rule.ErrorMessage ?? allFailure.Rule.RuleName;
onFailureFunc(eventName);
}

bool allFailure = ruleResultTrees.All(ruleResult => ruleResult.IsSuccess == false);
if (allFailure)
onFailureFunc();
return ruleResultTrees;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void OnFailWithSuccessTest()

var successEventName = true;

rulesResultTree.OnFail((eventName) => {
rulesResultTree.OnFail(() => {
successEventName = false;
});

Expand Down Expand Up @@ -203,7 +203,7 @@ public void OnFailWithoutSuccessTest()

var successEventName = true;

rulesResultTree.OnFail((eventName) => {
rulesResultTree.OnFail(() => {
successEventName = false;
});

Expand Down

0 comments on commit 57356f3

Please sign in to comment.