Example #1
0
        public void GetMatchingRules_NumericValueNotMatch_RuleNotReturned()
        {
            // Arrange
            IRulesService <TestModel> engine = RulesService <TestModel> .CreateDefault();

            // Act
            var numericValueTest       = 5;
            var numericValueOtherValue = 6;
            var matching = engine.GetMatchingRules(
                new TestModel {
                NumericField = numericValueTest
            },
                new[] {
                new RulesConfig {
                    Id            = Guid.NewGuid(),
                    RulesOperator = Rule.InterRuleOperatorType.And,
                    RulesGroups   = new RulesGroup[] {
                        new RulesGroup {
                            RulesOperator = Rule.InterRuleOperatorType.And,
                            Rules         = new[] {
                                new Rule {
                                    ComparisonOperator = Rule.ComparisonOperatorType.Equal, ComparisonValue = numericValueOtherValue.ToString(), ComparisonPredicate = nameof(TestModel.NumericField)
                                }
                            }
                        }
                    }
                }
            });

            // Assert
            Assert.Empty(matching.Data);
        }