-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix for ruleparameter name changes against cached rules * fixed indentation to match rest of code * suggested change implemented
- Loading branch information
Showing
2 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using RulesEngine.Models; | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Dynamic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace RulesEngine.UnitTest | ||
{ | ||
[ExcludeFromCodeCoverage] | ||
public class ParameterNameChangeTest | ||
{ | ||
[Fact] | ||
public async Task RunTwiceTest_ReturnsExpectedResults() | ||
{ | ||
var workflow = new Workflow { | ||
WorkflowName = "ParameterNameChangeWorkflow", | ||
Rules = new Rule[] { | ||
new Rule { | ||
RuleName = "ParameterNameChangeRule", | ||
RuleExpressionType = RuleExpressionType.LambdaExpression, | ||
Expression = "test.blah == 1" | ||
} | ||
} | ||
}; | ||
var engine = new RulesEngine(); | ||
engine.AddOrUpdateWorkflow(workflow); | ||
|
||
dynamic dynamicBlah = new ExpandoObject(); | ||
dynamicBlah.blah = (Int64)1; | ||
var input_pass = new RuleParameter("test", dynamicBlah); | ||
var input_fail = new RuleParameter("SOME_OTHER_NAME", dynamicBlah); | ||
// RuleParameter name matches expression, so should pass. | ||
var pass_results = await engine.ExecuteAllRulesAsync("ParameterNameChangeWorkflow", input_pass); | ||
// RuleParameter name DOES NOT MATCH expression, so should fail. | ||
var fail_results = await engine.ExecuteAllRulesAsync("ParameterNameChangeWorkflow", input_fail); | ||
Assert.True(pass_results.First().IsSuccess); | ||
Assert.False(fail_results.First().IsSuccess); | ||
} | ||
} | ||
} |