Add ContainsWorkflow method to check if workflow exists (#283)
* Add ContainsWorkflow method to check if workflow exists * Add method to interface Co-authored-by: anton.kheystver <anton.kheystver@opensoftdev.ru>pull/284/head
parent
108fa91968
commit
53213bf13e
|
@ -41,7 +41,14 @@ namespace RulesEngine.Interfaces
|
|||
/// Removes the workflow from RulesEngine
|
||||
/// </summary>
|
||||
/// <param name="workflowNames"></param>
|
||||
void RemoveWorkflow(params string[] workflowNames);
|
||||
void RemoveWorkflow(params string[] workflowNames);
|
||||
|
||||
/// <summary>
|
||||
/// Checks is workflow exist.
|
||||
/// </summary>
|
||||
/// <param name="workflowName">The workflow name.</param>
|
||||
/// <returns> <c>true</c> if contains the specified workflow name; otherwise, <c>false</c>.</returns>
|
||||
bool ContainsWorkflow(string workflowName);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the list of all registered workflow names
|
||||
|
|
|
@ -209,6 +209,16 @@ namespace RulesEngine
|
|||
public List<string> GetAllRegisteredWorkflowNames()
|
||||
{
|
||||
return _rulesCache.GetAllWorkflowNames();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks is workflow exist.
|
||||
/// </summary>
|
||||
/// <param name="workflowName">The workflow name.</param>
|
||||
/// <returns> <c>true</c> if contains the specified workflow name; otherwise, <c>false</c>.</returns>
|
||||
public bool ContainsWorkflow(string workflowName)
|
||||
{
|
||||
return _rulesCache.ContainsWorkflows(workflowName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -720,8 +720,31 @@ namespace RulesEngine.UnitTest
|
|||
List<RuleResultTree> result3 = await re.ExecuteAllRulesAsync("Exámple", input1);
|
||||
Assert.True(result3.All(c => c.IsSuccess));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ContainsWorkFlowName_ShouldReturn()
|
||||
{
|
||||
const string ExistedWorkflowName = "ExistedWorkflowName";
|
||||
const string NotExistedWorkflowName = "NotExistedWorkflowName";
|
||||
|
||||
var workflow = new Workflow {
|
||||
WorkflowName = ExistedWorkflowName,
|
||||
Rules = new Rule[]{
|
||||
new Rule {
|
||||
RuleName = "Rule",
|
||||
RuleExpressionType = RuleExpressionType.LambdaExpression,
|
||||
Expression = "1==1"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var re = new RulesEngine();
|
||||
re.AddWorkflow(workflow);
|
||||
|
||||
Assert.True(re.ContainsWorkflow(ExistedWorkflowName));
|
||||
Assert.False(re.ContainsWorkflow(NotExistedWorkflowName));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(typeof(RulesEngine),typeof(IRulesEngine))]
|
||||
|
|
Loading…
Reference in New Issue