Whenever an exception is occured in an execution. Error message will be transfered to the next runs.

pull/592/head
Taşkın Özdemir 2024-03-01 11:31:06 +03:00 committed by GitHub
parent a796094fa1
commit c69cb5df1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 32 additions and 1 deletions

View File

@ -836,7 +836,38 @@ namespace RulesEngine.UnitTest
Assert.All(result, rule => Assert.StartsWith("Error while executing rule :", rule.ExceptionMessage));
}
[Fact]
public async Task ExecuteRule_RuntimeErrorInPreviousRun_ShouldReturnEmptyErrorMessage()
{
var workflow = new Workflow {
WorkflowName = "TestWorkflow",
Rules = new[] {
new Rule {
RuleName = "ruleWithRuntimeError",
Expression = "input1.Country.ToLower() == \"india\""
}
}
};
var re = new RulesEngine(new[] { workflow }, null);
var input = new RuleTestClass {
Country = null
};
var result = await re.ExecuteAllRulesAsync("TestWorkflow", input);
Assert.NotNull(result);
Assert.All(result, rule => Assert.False(rule.IsSuccess));
Assert.All(result, rule => Assert.StartsWith("Error while executing rule :", rule.ExceptionMessage));
input.Country="india";
result = await re.ExecuteAllRulesAsync("TestWorkflow", input);
Assert.NotNull(result);
Assert.All(result, rule => Assert.True(rule.IsSuccess));
Assert.All(result, rule => Assert.Empty(rule.ExceptionMessage));
}
[Fact]
public async Task ExecuteRule_RuntimeError_ThrowsException()
{
@ -1166,4 +1197,4 @@ namespace RulesEngine.UnitTest
}
}
}
}