Exemplo n.º 1
0
        public void Init_GivenSetupWithStringValue_ReturnsSettedValues()
        {
            // Arrange
            ConditionType    expectedConditionType   = ConditionType.IsoCountryCode;
            Operators        expectedOperator        = Operators.NotEqual;
            string           expectedOperand         = "Such operand, much wow.";
            LogicalOperators expectedLogicalOperator = LogicalOperators.Eval;
            DataTypes        expectedDataType        = DataTypes.String;

            StringConditionNode <ConditionType> sut = new StringConditionNode <ConditionType>(expectedConditionType, expectedOperator, expectedOperand);

            // Act
            ConditionType    actualConditionType   = sut.ConditionType;
            Operators        actualOperator        = sut.Operator;
            DataTypes        actualDataType        = sut.DataType;
            LogicalOperators actualLogicalOperator = sut.LogicalOperator;
            string           actualOperand         = sut.Operand;

            // Assert
            actualConditionType.Should().Be(expectedConditionType);
            actualOperator.Should().Be(expectedOperator);
            actualOperand.Should().Be(expectedOperand);
            actualLogicalOperator.Should().Be(expectedLogicalOperator);
            actualDataType.Should().Be(expectedDataType);
        }
 public Func <IEnumerable <Condition <TConditionType> >, bool> GetDeferredEvalFor <TConditionType>(IValueConditionNode <TConditionType> valueConditionNode, MatchModes matchMode)
 {
     return(valueConditionNode switch
     {
         IntegerConditionNode <TConditionType> integerConditionNode => (conditions) => Eval <IntegerConditionNode <TConditionType>, TConditionType, int>(conditions, integerConditionNode, matchMode),
         DecimalConditionNode <TConditionType> decimalConditionNode => (conditions) => Eval <DecimalConditionNode <TConditionType>, TConditionType, decimal>(conditions, decimalConditionNode, matchMode),
         StringConditionNode <TConditionType> stringConditionNode => (conditions) => Eval <StringConditionNode <TConditionType>, TConditionType, string>(conditions, stringConditionNode, matchMode),
         BooleanConditionNode <TConditionType> booleanConditionNode => (conditions) => Eval <BooleanConditionNode <TConditionType>, TConditionType, bool>(conditions, booleanConditionNode, matchMode),
         _ => throw new NotSupportedException($"Unsupported value condition node: '{valueConditionNode.GetType().Name}'."),
     });
Exemplo n.º 3
0
        public void Eval_GivenComposedConditionNodeWithAndOperatorAndUnknownConditionNodeWithSearchMode_ThrowsNotSupportedException()
        {
            // Arrange
            StubConditionNode <ConditionType>   condition1 = new StubConditionNode <ConditionType>();
            StringConditionNode <ConditionType> condition2 = new StringConditionNode <ConditionType>(ConditionType.IsoCurrency, Operators.NotEqual, "SGD");

            ComposedConditionNode <ConditionType> composedConditionNode = new ComposedConditionNode <ConditionType>(
                LogicalOperators.Or,
                new IConditionNode <ConditionType>[] { condition1, condition2 });

            IEnumerable <Condition <ConditionType> > conditions = new[]
            {
                new Condition <ConditionType>
                {
                    Type  = ConditionType.IsoCurrency,
                    Value = "SGD"
                },
                new Condition <ConditionType>
                {
                    Type  = ConditionType.IsoCountryCode,
                    Value = "PT"
                }
            };

            EvaluationOptions evaluationOptions = new EvaluationOptions
            {
                MatchMode = MatchModes.Search,
                ExcludeRulesWithoutSearchConditions = true
            };

            Mock <IDeferredEval> mockDeferredEval = new Mock <IDeferredEval>();

            mockDeferredEval.SetupSequence(x => x.GetDeferredEvalFor(It.IsAny <IValueConditionNode <ConditionType> >(), It.Is <MatchModes>(mm => mm == MatchModes.Exact)))
            .Returns(() =>
            {
                return((c) => false);
            })
            .Returns(() =>
            {
                return((c) => true);
            })
            .Throws(new NotImplementedException("Shouldn't have gotten any more deferred evals."));

            ConditionsEvalEngine <ConditionType> sut = new ConditionsEvalEngine <ConditionType>(mockDeferredEval.Object);

            // Act
            NotSupportedException notSupportedException = Assert.Throws <NotSupportedException>(() => sut.Eval(composedConditionNode, conditions, evaluationOptions));

            // Assert
            notSupportedException.Should().NotBeNull();
            notSupportedException.Message.Should().Be("Unsupported condition node: 'StubConditionNode`1'.");
            mockDeferredEval.Verify(x => x.GetDeferredEvalFor(It.IsAny <IValueConditionNode <ConditionType> >(), It.Is <MatchModes>(mm => mm == MatchModes.Exact)), Times.Exactly(0));
        }
Exemplo n.º 4
0
        public void Eval_GivenComposedConditionNodeWithAndOperatorAndMissingConditionWithSearchMode_EvalsAndReturnsResult()
        {
            // Arrange
            BooleanConditionNode <ConditionType> condition1 = new BooleanConditionNode <ConditionType>(ConditionType.IsVip, Operators.Equal, true);
            StringConditionNode <ConditionType>  condition2 = new StringConditionNode <ConditionType>(ConditionType.IsoCurrency, Operators.NotEqual, "SGD");

            ComposedConditionNode <ConditionType> composedConditionNode = new ComposedConditionNode <ConditionType>(
                LogicalOperators.Or,
                new IConditionNode <ConditionType>[] { condition1, condition2 });

            IEnumerable <Condition <ConditionType> > conditions = new[]
            {
                new Condition <ConditionType>
                {
                    Type  = ConditionType.IsoCurrency,
                    Value = "SGD"
                },
                new Condition <ConditionType>
                {
                    Type  = ConditionType.IsoCountryCode,
                    Value = "PT"
                }
            };

            EvaluationOptions evaluationOptions = new EvaluationOptions
            {
                MatchMode = MatchModes.Search,
                ExcludeRulesWithoutSearchConditions = true
            };

            Mock <IDeferredEval> mockDeferredEval = new Mock <IDeferredEval>();

            mockDeferredEval.SetupSequence(x => x.GetDeferredEvalFor(It.IsAny <IValueConditionNode <ConditionType> >(), It.Is <MatchModes>(mm => mm == MatchModes.Exact)))
            .Returns(() =>
            {
                return((c) => false);
            })
            .Returns(() =>
            {
                return((c) => true);
            })
            .Throws(new NotImplementedException("Shouldn't have gotten any more deferred evals."));

            ConditionsEvalEngine <ConditionType> sut = new ConditionsEvalEngine <ConditionType>(mockDeferredEval.Object);

            // Act
            bool actual = sut.Eval(composedConditionNode, conditions, evaluationOptions);

            // Assert
            actual.Should().BeFalse();

            mockDeferredEval.Verify(x => x.GetDeferredEvalFor(It.IsAny <IValueConditionNode <ConditionType> >(), It.Is <MatchModes>(mm => mm == MatchModes.Exact)), Times.Exactly(0));
        }
Exemplo n.º 5
0
        public void GetDeferredEvalFor_GivenStringConditionNodeWithNoConditionSuppliedAndRulesEngineConfiguredToUseDataTypeDefaultWhenMissing_ReturnsFuncThatEvalsFalse()
        {
            // Arrange
            StringConditionNode <ConditionType> conditionNode = new StringConditionNode <ConditionType>(ConditionType.IsoCurrency, Operators.Equal, "EUR");

            Mock <IOperatorEvalStrategy> mockOperatorEvalStrategy = new Mock <IOperatorEvalStrategy>();

            mockOperatorEvalStrategy.Setup(x => x.Eval(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(false);

            Mock <IOperatorEvalStrategyFactory> mockOperatorEvalStrategyFactory = new Mock <IOperatorEvalStrategyFactory>();

            mockOperatorEvalStrategyFactory.Setup(x => x.GetOperatorEvalStrategy(It.IsAny <Operators>()))
            .Returns(mockOperatorEvalStrategy.Object);

            IEnumerable <Condition <ConditionType> > conditions = new Condition <ConditionType>[]
            {
                new Condition <ConditionType>
                {
                    Type  = ConditionType.IsoCountryCode,
                    Value = "PT"
                }
            };

            MatchModes matchMode = MatchModes.Exact;

            RulesEngineOptions rulesEngineOptions = RulesEngineOptions.NewWithDefaults();

            rulesEngineOptions.MissingConditionBehavior = MissingConditionBehaviors.UseDataTypeDefault;

            DeferredEval sut = new DeferredEval(mockOperatorEvalStrategyFactory.Object, rulesEngineOptions);

            // Act
            Func <IEnumerable <Condition <ConditionType> >, bool> actual = sut.GetDeferredEvalFor(conditionNode, matchMode);
            bool actualEvalResult = actual.Invoke(conditions);

            // Assert
            actualEvalResult.Should().BeFalse();

            mockOperatorEvalStrategyFactory.Verify(x => x.GetOperatorEvalStrategy(It.IsAny <Operators>()), Times.Once());
            mockOperatorEvalStrategy.Verify(x => x.Eval(It.IsAny <string>(), It.IsAny <string>()), Times.Once());
        }
Exemplo n.º 6
0
        public void Eval_GivenComposedConditionNodeWithEvalOperator_ThrowsNotSupportedException()
        {
            // Arrange
            BooleanConditionNode <ConditionType> condition1 = new BooleanConditionNode <ConditionType>(ConditionType.IsVip, Operators.Equal, true);
            StringConditionNode <ConditionType>  condition2 = new StringConditionNode <ConditionType>(ConditionType.IsoCurrency, Operators.NotEqual, "SGD");

            ComposedConditionNode <ConditionType> composedConditionNode = new ComposedConditionNode <ConditionType>(
                LogicalOperators.Eval,
                new IConditionNode <ConditionType>[] { condition1, condition2 });

            IEnumerable <Condition <ConditionType> > conditions = new[]
            {
                new Condition <ConditionType>
                {
                    Type  = ConditionType.IsoCurrency,
                    Value = "SGD"
                },
                new Condition <ConditionType>
                {
                    Type  = ConditionType.IsVip,
                    Value = true
                }
            };

            EvaluationOptions evaluationOptions = new EvaluationOptions
            {
                MatchMode = MatchModes.Exact
            };

            Mock <IDeferredEval> mockDeferredEval = new Mock <IDeferredEval>();

            ConditionsEvalEngine <ConditionType> sut = new ConditionsEvalEngine <ConditionType>(mockDeferredEval.Object);

            // Act
            NotSupportedException notSupportedException = Assert.Throws <NotSupportedException>(() => sut.Eval(composedConditionNode, conditions, evaluationOptions));

            // Assert
            notSupportedException.Should().NotBeNull();
            notSupportedException.Message.Should().Be("Unsupported logical operator: 'Eval'.");
            mockDeferredEval.Verify(x => x.GetDeferredEvalFor(It.IsAny <IValueConditionNode <ConditionType> >(), It.Is <MatchModes>(mm => mm == MatchModes.Exact)), Times.Never());
        }
Exemplo n.º 7
0
        public void GetDeferredEvalFor_GivenStringConditionNode_ReturnsFuncToEvalConditionsCollection()
        {
            // Arrange
            StringConditionNode <ConditionType> conditionNode = new StringConditionNode <ConditionType>(ConditionType.IsoCurrency, Operators.Equal, "EUR");

            Mock <IOperatorEvalStrategy> mockOperatorEvalStrategy = new Mock <IOperatorEvalStrategy>();

            mockOperatorEvalStrategy.Setup(x => x.Eval(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(true);

            Mock <IOperatorEvalStrategyFactory> mockOperatorEvalStrategyFactory = new Mock <IOperatorEvalStrategyFactory>();

            mockOperatorEvalStrategyFactory.Setup(x => x.GetOperatorEvalStrategy(It.IsAny <Operators>()))
            .Returns(mockOperatorEvalStrategy.Object);

            IEnumerable <Condition <ConditionType> > conditions = new Condition <ConditionType>[]
            {
                new Condition <ConditionType>
                {
                    Type  = ConditionType.IsoCurrency,
                    Value = "EUR"
                }
            };

            MatchModes matchMode = MatchModes.Exact;

            RulesEngineOptions rulesEngineOptions = RulesEngineOptions.NewWithDefaults();

            DeferredEval sut = new DeferredEval(mockOperatorEvalStrategyFactory.Object, rulesEngineOptions);

            // Act
            Func <IEnumerable <Condition <ConditionType> >, bool> actual = sut.GetDeferredEvalFor(conditionNode, matchMode);
            bool actualEvalResult = actual.Invoke(conditions);

            // Assert
            actualEvalResult.Should().BeTrue();

            mockOperatorEvalStrategyFactory.Verify(x => x.GetOperatorEvalStrategy(It.IsAny <Operators>()), Times.Once());
            mockOperatorEvalStrategy.Verify(x => x.Eval(It.IsAny <string>(), It.IsAny <string>()), Times.Once());
        }
        public void CreateRule_GivenRuleDataModelWithComposedNodeAndChildNodesOfEachDataType_ReturnsRuleInstance()
        {
            // Arrange
            dynamic content = new ExpandoObject();

            content.Prop1 = 123;
            content.Prop2 = "Sample string";
            content.Prop3 = 500.34m;

            ValueConditionNodeDataModel integerConditionNodeDataModel = new ValueConditionNodeDataModel
            {
                ConditionType   = "SampleIntegerCondition",
                DataType        = DataTypes.Integer,
                LogicalOperator = LogicalOperators.Eval,
                Operand         = 20,
                Operator        = Operators.GreaterThan
            };

            ValueConditionNodeDataModel stringConditionNodeDataModel = new ValueConditionNodeDataModel
            {
                ConditionType   = "SampleStringCondition",
                DataType        = DataTypes.String,
                LogicalOperator = LogicalOperators.Eval,
                Operand         = "TEST",
                Operator        = Operators.Equal
            };

            ValueConditionNodeDataModel decimalConditionNodeDataModel = new ValueConditionNodeDataModel
            {
                ConditionType   = "SampleDecimalCondition",
                DataType        = DataTypes.Decimal,
                LogicalOperator = LogicalOperators.Eval,
                Operand         = 50.3m,
                Operator        = Operators.LesserThanOrEqual
            };

            ValueConditionNodeDataModel booleanConditionNodeDataModel = new ValueConditionNodeDataModel
            {
                ConditionType   = "SampleBooleanCondition",
                DataType        = DataTypes.Boolean,
                LogicalOperator = LogicalOperators.Eval,
                Operand         = true,
                Operator        = Operators.NotEqual
            };

            RuleDataModel ruleDataModel = new RuleDataModel
            {
                Content       = content,
                ContentType   = "ContentTypeSample",
                DateBegin     = new System.DateTime(2020, 1, 1),
                DateEnd       = null,
                Id            = ObjectId.GenerateNewId(),
                Name          = "My rule used for testing purposes",
                Priority      = 1,
                RootCondition = new ComposedConditionNodeDataModel
                {
                    LogicalOperator     = LogicalOperators.And,
                    ChildConditionNodes = new ConditionNodeDataModel[]
                    {
                        integerConditionNodeDataModel,
                        stringConditionNodeDataModel,
                        decimalConditionNodeDataModel,
                        booleanConditionNodeDataModel
                    }
                }
            };

            IContentSerializationProvider <ContentType> contentSerializationProvider = Mock.Of <IContentSerializationProvider <ContentType> >();

            RuleFactory <ContentType, ConditionType> ruleFactory = new RuleFactory <ContentType, ConditionType>(contentSerializationProvider);

            // Act
            Rule <ContentType, ConditionType> rule = ruleFactory.CreateRule(ruleDataModel);

            // Assert
            rule.Should().NotBeNull();
            rule.ContentContainer.Should().NotBeNull()
            .And.BeOfType <SerializedContentContainer <ContentType> >();
            rule.DateBegin.Should().Be(ruleDataModel.DateBegin);
            rule.DateEnd.Should().BeNull();
            rule.Name.Should().Be(ruleDataModel.Name);
            rule.Priority.Should().Be(ruleDataModel.Priority);
            rule.RootCondition.Should().BeOfType <ComposedConditionNode <ConditionType> >();

            ComposedConditionNode <ConditionType> composedConditionNode = rule.RootCondition.As <ComposedConditionNode <ConditionType> >();

            composedConditionNode.LogicalOperator.Should().Be(LogicalOperators.And);
            composedConditionNode.ChildConditionNodes.Should().HaveCount(4);

            IEnumerable <IntegerConditionNode <ConditionType> > integerConditionNodes = composedConditionNode.ChildConditionNodes.OfType <IntegerConditionNode <ConditionType> >();

            integerConditionNodes.Should().HaveCount(1);
            IntegerConditionNode <ConditionType> integerConditionNode = integerConditionNodes.First();

            integerConditionNode.Should().NotBeNull();
            integerConditionNode.ConditionType.Should().Match <ConditionType>(x => x == Enum.Parse <ConditionType>(integerConditionNodeDataModel.ConditionType));
            integerConditionNode.DataType.Should().Be(integerConditionNodeDataModel.DataType);
            integerConditionNode.LogicalOperator.Should().Be(integerConditionNodeDataModel.LogicalOperator);
            integerConditionNode.Operand.Should().Match(x => object.Equals(x, integerConditionNodeDataModel.Operand));
            integerConditionNode.Operator.Should().Be(integerConditionNodeDataModel.Operator);

            IEnumerable <StringConditionNode <ConditionType> > stringConditionNodes = composedConditionNode.ChildConditionNodes.OfType <StringConditionNode <ConditionType> >();

            stringConditionNodes.Should().HaveCount(1);
            StringConditionNode <ConditionType> stringConditionNode = stringConditionNodes.First();

            stringConditionNode.Should().NotBeNull();
            stringConditionNode.ConditionType.Should().Match <ConditionType>(x => x == Enum.Parse <ConditionType>(stringConditionNodeDataModel.ConditionType));
            stringConditionNode.DataType.Should().Be(stringConditionNodeDataModel.DataType);
            stringConditionNode.LogicalOperator.Should().Be(stringConditionNodeDataModel.LogicalOperator);
            stringConditionNode.Operand.Should().Match(x => object.Equals(x, stringConditionNodeDataModel.Operand));
            stringConditionNode.Operator.Should().Be(stringConditionNodeDataModel.Operator);

            IEnumerable <DecimalConditionNode <ConditionType> > decimalConditionNodes = composedConditionNode.ChildConditionNodes.OfType <DecimalConditionNode <ConditionType> >();

            decimalConditionNodes.Should().HaveCount(1);
            DecimalConditionNode <ConditionType> decimalConditionNode = decimalConditionNodes.First();

            decimalConditionNode.Should().NotBeNull();
            decimalConditionNode.ConditionType.Should().Match <ConditionType>(x => x == Enum.Parse <ConditionType>(decimalConditionNodeDataModel.ConditionType));
            decimalConditionNode.DataType.Should().Be(decimalConditionNodeDataModel.DataType);
            decimalConditionNode.LogicalOperator.Should().Be(decimalConditionNodeDataModel.LogicalOperator);
            decimalConditionNode.Operand.Should().Match(x => object.Equals(x, decimalConditionNodeDataModel.Operand));
            decimalConditionNode.Operator.Should().Be(decimalConditionNodeDataModel.Operator);

            IEnumerable <BooleanConditionNode <ConditionType> > booleanConditionNodes = composedConditionNode.ChildConditionNodes.OfType <BooleanConditionNode <ConditionType> >();

            booleanConditionNodes.Should().HaveCount(1);
            BooleanConditionNode <ConditionType> booleanConditionNode = booleanConditionNodes.First();

            booleanConditionNode.Should().NotBeNull();
            booleanConditionNode.ConditionType.Should().Match <ConditionType>(x => x == Enum.Parse <ConditionType>(booleanConditionNodeDataModel.ConditionType));
            booleanConditionNode.DataType.Should().Be(booleanConditionNodeDataModel.DataType);
            booleanConditionNode.LogicalOperator.Should().Be(booleanConditionNodeDataModel.LogicalOperator);
            booleanConditionNode.Operand.Should().Be(Convert.ToBoolean(booleanConditionNodeDataModel.Operand));
            booleanConditionNode.Operator.Should().Be(booleanConditionNodeDataModel.Operator);
        }
        public void CreateRule_GivenRuleWithComposedNodeAndChildNodesOfEachDataType_ReturnsRuleDataModelInstance()
        {
            // Arrange
            dynamic content = new ExpandoObject();

            content.Prop1 = 123;
            content.Prop2 = "Sample string";
            content.Prop3 = 500.34m;

            IContentSerializer contentSerializer = Mock.Of <IContentSerializer>();

            Mock.Get(contentSerializer)
            .Setup(x => x.Deserialize(It.IsAny <object>(), It.IsAny <Type>()))
            .Returns((object)content);

            IContentSerializationProvider <ContentType> contentSerializationProvider = Mock.Of <IContentSerializationProvider <ContentType> >();

            Mock.Get(contentSerializationProvider)
            .Setup(x => x.GetContentSerializer(ContentType.ContentTypeSample))
            .Returns(contentSerializer);

            BooleanConditionNode <ConditionType> booleanConditionNode = null;
            DecimalConditionNode <ConditionType> decimalConditionNode = null;
            IntegerConditionNode <ConditionType> integerConditionNode = null;
            StringConditionNode <ConditionType>  stringConditionNode  = null;

            Rule <ContentType, ConditionType> rule1 = RuleBuilder.NewRule <ContentType, ConditionType>()
                                                      .WithName("My rule used for testing purposes")
                                                      .WithDateBegin(new DateTime(2020, 1, 1))
                                                      .WithPriority(1)
                                                      .WithSerializedContent(ContentType.ContentTypeSample, (object)content, contentSerializationProvider)
                                                      .WithCondition(cnb => cnb.AsComposed()
                                                                     .WithLogicalOperator(LogicalOperators.And)
                                                                     .AddCondition(cnb1 => booleanConditionNode = cnb1.AsValued(ConditionType.SampleBooleanCondition)
                                                                                                                  .OfDataType <bool>()
                                                                                                                  .WithComparisonOperator(Operators.NotEqual)
                                                                                                                  .SetOperand(true)
                                                                                                                  .Build() as BooleanConditionNode <ConditionType>)
                                                                     .AddCondition(cnb1 => decimalConditionNode = cnb1.AsValued(ConditionType.SampleDecimalCondition)
                                                                                                                  .OfDataType <decimal>()
                                                                                                                  .WithComparisonOperator(Operators.LesserThanOrEqual)
                                                                                                                  .SetOperand(50.3m)
                                                                                                                  .Build() as DecimalConditionNode <ConditionType>)
                                                                     .AddCondition(cnb1 => integerConditionNode = cnb1.AsValued(ConditionType.SampleIntegerCondition)
                                                                                                                  .OfDataType <int>()
                                                                                                                  .WithComparisonOperator(Operators.GreaterThan)
                                                                                                                  .SetOperand(20)
                                                                                                                  .Build() as IntegerConditionNode <ConditionType>)
                                                                     .AddCondition(cnb1 => stringConditionNode = cnb1.AsValued(ConditionType.SampleStringCondition)
                                                                                                                 .OfDataType <string>()
                                                                                                                 .WithComparisonOperator(Operators.Equal)
                                                                                                                 .SetOperand("TEST")
                                                                                                                 .Build() as StringConditionNode <ConditionType>)
                                                                     .Build())
                                                      .Build().Rule;

            RuleFactory <ContentType, ConditionType> ruleFactory = new RuleFactory <ContentType, ConditionType>(contentSerializationProvider);

            // Act
            RuleDataModel rule = ruleFactory.CreateRule(rule1);

            // Assert
            rule.Should().NotBeNull();
            object content1 = rule.Content;

            content1.Should().NotBeNull()
            .And.BeSameAs(content);
            rule.DateBegin.Should().Be(rule.DateBegin);
            rule.DateEnd.Should().BeNull();
            rule.Name.Should().Be(rule.Name);
            rule.Priority.Should().Be(rule.Priority);
            rule.RootCondition.Should().BeOfType <ComposedConditionNodeDataModel>();

            ComposedConditionNodeDataModel composedConditionNodeDataModel = rule.RootCondition.As <ComposedConditionNodeDataModel>();

            composedConditionNodeDataModel.LogicalOperator.Should().Be(LogicalOperators.And);
            composedConditionNodeDataModel.ChildConditionNodes.Should().HaveCount(4);

            IEnumerable <ValueConditionNodeDataModel> valueConditionNodeDataModels = composedConditionNodeDataModel.ChildConditionNodes.OfType <ValueConditionNodeDataModel>();

            valueConditionNodeDataModels.Should().HaveCount(4);
            ValueConditionNodeDataModel integerConditionNodeDataModel = valueConditionNodeDataModels.First(v => v.DataType == DataTypes.Integer);

            integerConditionNodeDataModel.Should().NotBeNull();
            integerConditionNodeDataModel.ConditionType.Should().Match <string>(x => integerConditionNode.ConditionType == Enum.Parse <ConditionType>(x));
            integerConditionNodeDataModel.DataType.Should().Be(integerConditionNode.DataType);
            integerConditionNodeDataModel.LogicalOperator.Should().Be(integerConditionNode.LogicalOperator);
            integerConditionNodeDataModel.Operand.Should().Match(x => object.Equals(x, integerConditionNode.Operand));
            integerConditionNodeDataModel.Operator.Should().Be(integerConditionNode.Operator);

            ValueConditionNodeDataModel stringConditionNodeDataModel = valueConditionNodeDataModels.First(v => v.DataType == DataTypes.String);

            stringConditionNodeDataModel.Should().NotBeNull();
            stringConditionNodeDataModel.ConditionType.Should().Match <string>(x => stringConditionNode.ConditionType == Enum.Parse <ConditionType>(x));
            stringConditionNodeDataModel.DataType.Should().Be(stringConditionNode.DataType);
            stringConditionNodeDataModel.LogicalOperator.Should().Be(stringConditionNode.LogicalOperator);
            stringConditionNodeDataModel.Operand.Should().Match(x => object.Equals(x, stringConditionNode.Operand));
            stringConditionNodeDataModel.Operator.Should().Be(stringConditionNode.Operator);

            ValueConditionNodeDataModel decimalConditionNodeDataModel = valueConditionNodeDataModels.First(v => v.DataType == DataTypes.Decimal);

            decimalConditionNodeDataModel.Should().NotBeNull();
            decimalConditionNodeDataModel.ConditionType.Should().Match <string>(x => decimalConditionNode.ConditionType == Enum.Parse <ConditionType>(x));
            decimalConditionNodeDataModel.DataType.Should().Be(decimalConditionNode.DataType);
            decimalConditionNodeDataModel.LogicalOperator.Should().Be(decimalConditionNode.LogicalOperator);
            decimalConditionNodeDataModel.Operand.Should().Match(x => object.Equals(x, decimalConditionNode.Operand));
            decimalConditionNodeDataModel.Operator.Should().Be(decimalConditionNode.Operator);

            ValueConditionNodeDataModel booleanConditionNodeDataModel = valueConditionNodeDataModels.First(v => v.DataType == DataTypes.Boolean);

            booleanConditionNodeDataModel.Should().NotBeNull();
            booleanConditionNodeDataModel.ConditionType.Should().Match <string>(x => booleanConditionNode.ConditionType == Enum.Parse <ConditionType>(x));
            booleanConditionNodeDataModel.DataType.Should().Be(booleanConditionNode.DataType);
            booleanConditionNodeDataModel.LogicalOperator.Should().Be(booleanConditionNode.LogicalOperator);
            booleanConditionNodeDataModel.Operand.Should().Be(Convert.ToBoolean(booleanConditionNode.Operand));
            booleanConditionNodeDataModel.Operator.Should().Be(booleanConditionNode.Operator);
        }