public void ShouldGetReverseFilterTypeWhenGivenSingleItemAndInvokeNot() { var filter = FilterInfo.CreateItem("Age", Operator.GreaterThan, 1).Not(); filter.OpType.Should().Be(CombinSymbol.SingleItem); filter.Operator.Should().Be(Operator.LessThanOrEqual); filter.Left.Should().BeEquivalentTo(ValueInfo.Parse("Age")); filter.Right.Should().BeEquivalentTo(ValueInfo.FromConstantValue(1)); }
public void ShouldGetExpectedExpressionFromNullableMemberPaths(string path, string expectedExpression) { var valueInfo = ValueInfo.Parse(path); var memberVisitor = IMemberVisitor.GetObjectVisitor(typeof(SourceNullableClass)); IValueLambdaProvider constLambda = new PathValueLambdaProvider(typeof(SourceNullableClass), valueInfo.NavigatePaths, memberVisitor); var lambda = constLambda.GetLambda(); lambda.ToString().Should().Be(expectedExpression); }
public static FilterInfo CreateItem(string fieldPaths, Operator filterType, object value) { return(new FilterInfo() { OpType = CombinSymbol.SingleItem, Operator = filterType, Left = ValueInfo.Parse(fieldPaths), Right = new ValueInfo { IsConstant = true, ConstantValue = value } }); }
public void ShouldGetReverseFilterTypeWhenGivenOrOpTypeAndInvokeNot() { var filter = FilterInfo.CreateItem("Age", Operator.GreaterThan, 1) .OrElse("Name", Operator.StartsWith, "Zhang").Not(); filter.OpType.Should().Be(CombinSymbol.AndItems); filter.Items.Count.Should().Be(2); filter.Items.First().Left.Should().BeEquivalentTo(ValueInfo.Parse("Age")); filter.Items.First().Operator.Should().Be(Operator.LessThanOrEqual); filter.Items.First().Right.Should().BeEquivalentTo(ValueInfo.FromConstantValue(1)); filter.Items.Last().Left.Should().BeEquivalentTo(ValueInfo.Parse("Name")); filter.Items.Last().Operator.Should().Be(Operator.NotStartsWith); filter.Items.Last().Right.Should().BeEquivalentTo(ValueInfo.FromConstantValue("Zhang")); }