예제 #1
0
 private static ConditionExpressionTree GetPricingDynamicExpression()
 {
     var conditions = new DynamicExpression[] { new ConditionGeoTimeZone(), new ConditionGeoZipCode(), new ConditionStoreSearchedPhrase(), new ConditionAgeIs(), new ConditionGenderIs(), new ConditionGeoCity(), new ConditionGeoCountry(), new ConditionGeoState(), new ConditionLanguageIs(), new TagsContainsCondition() }.ToList();
     var rootBlock = new BlockPricingCondition { AvailableChildren = conditions };
     var retVal = new ConditionExpressionTree()
     {
         Children = new DynamicExpression[] { rootBlock }
     };
     return retVal;
 }
예제 #2
0
        private static IConditionTree GetPricingDynamicExpression()
        {
            var conditions = new List <IConditionTree>
            {
                new ConditionGeoTimeZone(), new ConditionGeoZipCode(), new ConditionStoreSearchedPhrase(), new ConditionAgeIs(), new ConditionGenderIs(),
                new ConditionGeoCity(), new ConditionGeoCountry(), new ConditionGeoState(), new ConditionLanguageIs(), new UserGroupsContainsCondition()
            };
            var rootBlock = new BlockPricingCondition {
                AvailableChildren = conditions
            };

            return(rootBlock);
        }
예제 #3
0
        private static ConditionExpressionTree GetPricingDynamicExpression()
        {
            var conditions = new DynamicExpression[] { new ConditionGeoTimeZone(), new ConditionGeoZipCode(), new ConditionStoreSearchedPhrase(), new ConditionAgeIs(), new ConditionGenderIs(), new ConditionGeoCity(), new ConditionGeoCountry(), new ConditionGeoState(), new ConditionLanguageIs() }.ToList();
            var rootBlock = new BlockPricingCondition {
                AvailableChildren = conditions
            };
            var retVal = new ConditionExpressionTree()
            {
                Children = new DynamicExpression[] { rootBlock }
            };

            return(retVal);
        }
예제 #4
0
        public async Task TestConditionSerialization()
        {
            // Arrange
            var condition = new BlockPricingCondition
            {
                All      = false,
                Children = new List <IConditionTree>
                {
                    new ConditionStoreSearchedPhrase
                    {
                        MatchCondition = ConditionOperation.Contains,
                        Value          = "test"
                    },
                    new ConditionGenderIs
                    {
                        MatchCondition = ConditionOperation.Matching,
                        Value          = "male"
                    },
                    new ConditionAgeIs
                    {
                        CompareCondition = ConditionOperation.IsGreaterThanOrEqual,
                        Value            = 18
                    }
                }
            };

            var conditionTree = new PriceConditionTree
            {
                Children = new List <IConditionTree> {
                    condition
                }
            };

            var serializedConditionTree = (await ReadTextFromEmbeddedResourceAsync("Resources.TestSerializedCondition.json"))?.Trim();

            //// Act
            var actualResult = JsonConvert.SerializeObject(conditionTree);

            // Assert
            Assert.Equal(serializedConditionTree, actualResult);
        }