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; }
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); }
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); }
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); }