コード例 #1
0
        public void Match_returns_false_when_properties_does_not_contain_criterion_for_property()
        {
            var sut = new CriterionGroup
            {
                Criterions = new List <Criterion>
                {
                    new Criterion
                    {
                        PropertyAlias = "blahroiewhwoer",
                        PropertyValue = "does not matter",
                        Operator      = new Operator
                        {
                            DataType     = DataTypeEnum.String,
                            OperatorType = OperatorTypeEnum.Equals,
                            IsInverted   = true
                        }
                    }
                }
            };

            var actual = sut.Match(new Dictionary <string, object>
            {
                ["something"] = 24
            });

            Assert.False(actual);
        }
コード例 #2
0
        public void Match_throws_ArgumentNullException_when_properties_is_null()
        {
            var sut = new CriterionGroup();

            Func <object> test = () => sut.Match(null);

            Assert.Throws <ArgumentNullException>(test);
        }
コード例 #3
0
        public void Match_returns_true_when_Criterions_is_empty()
        {
            var sut = new CriterionGroup {
                Criterions = new List <Criterion>()
            };

            var actual = sut.Match(new Dictionary <string, object>());

            Assert.True(actual);
        }
コード例 #4
0
        public void Match_returns_true_if_one_of_n_criterions_matches(string referrer, string queryString, bool expected)
        {
            var sut = new CriterionGroup
            {
                Criterions = new List <Criterion>
                {
                    new Criterion
                    {
                        PropertyAlias = "httpReferrer",
                        PropertyValue = "facebook",
                        Operator      = new Operator
                        {
                            DataType     = DataTypeEnum.String,
                            OperatorType = OperatorTypeEnum.Contains
                        }
                    },
                    new Criterion
                    {
                        PropertyAlias = "queryString",
                        PropertyValue = "utm_source=facebook",
                        Operator      = new Operator
                        {
                            DataType     = DataTypeEnum.String,
                            OperatorType = OperatorTypeEnum.Contains
                        }
                    }
                }
            };

            var actual = sut.Match(new Dictionary <string, object>
            {
                ["httpReferrer"] = referrer,
                ["queryString"]  = queryString
            });

            Assert.Equal(expected, actual);
        }