public void BindApplyWithAggregateAndFilterShouldReturnApplyClause() { IEnumerable <QueryToken> tokens = _parser.ParseApply("aggregate(StockQuantity with sum as TotalPrice)/filter(TotalPrice eq 100)"); MetadataBinder metadataBiner = new MetadataBinder(_bindingState); ApplyBinder binder = new ApplyBinder(metadataBiner.Bind, _bindingState); ApplyClause actual = binder.BindApply(tokens); actual.Should().NotBeNull(); actual.Transformations.Should().HaveCount(2); List <TransformationNode> transformations = actual.Transformations.ToList(); FilterTransformationNode filter = transformations[1] as FilterTransformationNode; filter.Should().NotBeNull(); filter.Kind.Should().Be(TransformationNodeKind.Filter); FilterClause filterClause = filter.FilterClause; filterClause.Expression.Should().NotBeNull(); BinaryOperatorNode binaryOperation = filterClause.Expression as BinaryOperatorNode; binaryOperation.Should().NotBeNull(); ConvertNode propertyConvertNode = binaryOperation.Left as ConvertNode; propertyConvertNode.Should().NotBeNull(); SingleValueOpenPropertyAccessNode propertyAccess = propertyConvertNode.Source as SingleValueOpenPropertyAccessNode; propertyAccess.Should().NotBeNull(); propertyAccess.Name.Should().Be("TotalPrice"); }
public void BindApplyWitFilterShouldReturnApplyClause() { IEnumerable <QueryToken> tokens = _parser.ParseApply("filter(UnitPrice eq 5)"); ApplyBinder binder = new ApplyBinder(BindMethodReturnsBooleanPrimitive, _bindingState); ApplyClause actual = binder.BindApply(tokens); actual = binder.BindApply(tokens); actual.Should().NotBeNull(); actual.Transformations.Should().HaveCount(1); List <TransformationNode> transformations = actual.Transformations.ToList(); FilterTransformationNode filter = transformations[0] as FilterTransformationNode; filter.Should().NotBeNull(); filter.Kind.Should().Be(TransformationNodeKind.Filter); filter.FilterClause.Expression.Should().NotBeNull(); filter.FilterClause.Expression.Should().BeSameAs(_booleanPrimitiveNode); }