public void FormatGremlinFilterShouldReturnIteratorSyntaxForSingleCaseSensititiveNotEqualFilterStringValue()
        {
            var filters = new List <Filter>
            {
                new Filter {
                    PropertyName = "Foo", Value = "Bar", ExpressionType = ExpressionType.NotEqual
                }
            };
            var baseQuery = new GremlinQuery(null, null, new Dictionary <string, object>(), new List <string>());
            var filter    = FilterFormatters.FormatGremlinFilter(filters, StringComparison.Ordinal, baseQuery);

            Assert.Equal(".filter{ !it[p0].equals(p1) }", filter.FilterText);
            Assert.Equal("Foo", filter.FilterParameters["p0"]);
            Assert.Equal("Bar", filter.FilterParameters["p1"]);
        }
        public void FormatGremlinFilterShouldReturnIteratorSyntaxForSingleCaseInsensititiveEqualFilterWithNullableEnumValue()
        {
            var filters = new List <Filter>
            {
                new Filter {
                    PropertyName = "Foo", Value = (EnumForTesting?)EnumForTesting.Bar, ExpressionType = ExpressionType.Equal
                },
            };
            var baseQuery = new GremlinQuery(null, null, new Dictionary <string, object>(), new List <string>());
            var filter    = FilterFormatters.FormatGremlinFilter(filters, StringComparison.OrdinalIgnoreCase, baseQuery);

            Assert.Equal(".filter{ it[p0].equalsIgnoreCase(p1) }", filter.FilterText);
            Assert.Equal("Foo", filter.FilterParameters["p0"]);
            Assert.Equal("Bar", filter.FilterParameters["p1"]);
        }
        public void FormatGremlinFilterShouldReturnIteratorSyntaxForSingleCaseInsensititiveNotEqualFilterMaxLongValue()
        {
            var filters = new List <Filter>
            {
                new Filter {
                    PropertyName = "Foo", Value = 9223372036854775807, ExpressionType = ExpressionType.NotEqual
                },
            };
            var baseQuery = new GremlinQuery(null, null, new Dictionary <string, object>(), new List <string>());
            var filter    = FilterFormatters.FormatGremlinFilter(filters, StringComparison.OrdinalIgnoreCase, baseQuery);

            Assert.Equal(".filter{ it[p0] != p1 }", filter.FilterText);
            Assert.Equal("Foo", filter.FilterParameters["p0"]);
            Assert.Equal(9223372036854775807, filter.FilterParameters["p1"]);
        }
        public void FormatGremlinFilterShouldReturnIndexerSyntaxForSingleCaseSensititiveEqualFilterWithLongMaxValue()
        {
            var filters = new List <Filter>
            {
                new Filter {
                    PropertyName = "Foo", Value = long.MaxValue, ExpressionType = ExpressionType.Equal
                }
            };
            var baseQuery = new GremlinQuery(null, null, new Dictionary <string, object>(), new List <string>());
            var filter    = FilterFormatters.FormatGremlinFilter(filters, StringComparison.Ordinal, baseQuery);

            Assert.Equal(".filter{ it[p0] == p1 }", filter.FilterText);
            Assert.Equal("Foo", filter.FilterParameters["p0"]);
            Assert.Equal(9223372036854775807, filter.FilterParameters["p1"]);
        }
        public void TranslateFilterShouldResolveThreePropertiesEqualNullWithBinaryAndAlso()
        {
            var filters = FilterFormatters
                          .TranslateFilter <Foo>(f => f.Prop1 == null && f.Prop2 == null && f.Prop3 == null)
                          .OrderBy(f => f.PropertyName)
                          .ToArray();

            Assert.AreEqual(3, filters.Count());
            Assert.AreEqual("Prop1", filters[0].PropertyName);
            Assert.AreEqual(null, filters[0].Value);
            Assert.AreEqual("Prop2", filters[1].PropertyName);
            Assert.AreEqual(null, filters[1].Value);
            Assert.AreEqual("Prop3", filters[2].PropertyName);
            Assert.AreEqual(null, filters[2].Value);
        }
        public void TranslateFilterShouldResolveSinglePropertyEqualsAnotherStringPropertyExpression()
        {
            var bar = new Bar {
                Prop1 = "def"
            };
            var filters = FilterFormatters
                          .TranslateFilter <Foo>(
                f => f.Prop1 == bar.Prop1     // This must be a property get - do not refactor this line
                )
                          .ToArray();

            Assert.AreEqual(1, filters.Count());
            Assert.AreEqual("Prop1", filters.FirstOrDefault().PropertyName);
            Assert.AreEqual("def", filters.FirstOrDefault().Value);
        }
예제 #7
0
        public void FormatGremlinFilterShouldSupportGuidTypeInNotEqualsExpression()
        {
            const string guidString = "1a4e451c-aa87-4388-9b53-5d00b05ac728";
            var          guidValue  = Guid.Parse(guidString);

            var filters = new List <Filter>
            {
                new Filter {
                    PropertyName = "Foo", Value = guidValue, ExpressionType = ExpressionType.NotEqual
                }
            };
            var baseQuery = new GremlinQuery(null, null, new Dictionary <string, object>(), new List <string>());
            var filter    = FilterFormatters.FormatGremlinFilter(filters, StringComparison.Ordinal, baseQuery);

            Assert.AreEqual(".filter{ it[p0] != p1 }", filter.FilterText);
            Assert.AreEqual("Foo", filter.FilterParameters["p0"]);
            Assert.AreEqual(guidString, filter.FilterParameters["p1"].ToString());
        }
예제 #8
0
        public void FormatGremlinFilterShouldReturnIteratorSyntaxForMultipleCaseInsensititiveEqualFiltersWithStringValues()
        {
            var filters = new List <Filter>
            {
                new Filter {
                    PropertyName = "Foo", Value = "Bar", ExpressionType = ExpressionType.Equal
                },
                new Filter {
                    PropertyName = "Baz", Value = "Qak", ExpressionType = ExpressionType.Equal
                },
            };
            var baseQuery = new GremlinQuery(null, null, new Dictionary <string, object>(), new List <string>());
            var filter    = FilterFormatters.FormatGremlinFilter(filters, StringComparison.OrdinalIgnoreCase, baseQuery);

            Assert.AreEqual(".filter{ it[p0].equalsIgnoreCase(p1) && it[p2].equalsIgnoreCase(p3) }", filter.FilterText);
            Assert.AreEqual("Foo", filter.FilterParameters["p0"]);
            Assert.AreEqual("Bar", filter.FilterParameters["p1"]);
            Assert.AreEqual("Baz", filter.FilterParameters["p2"]);
            Assert.AreEqual("Qak", filter.FilterParameters["p3"]);
        }
예제 #9
0
        public void TranslateFilterShouldResolveThreePropertiesEqualOtherStringPropertiesInBooleanAndAlsoChain()
        {
            var bar = new Bar {
                Prop1 = "def", Prop2 = "ghi", Prop3 = "jkl"
            };
            var filters = FilterFormatters
                          .TranslateFilter <Foo>(
                // These must be property gets - do not refactor this line
                f => f.Prop1 == bar.Prop1 && f.Prop2 == bar.Prop2 && f.Prop3 == bar.Prop3
                )
                          .OrderBy(f => f.PropertyName)
                          .ToArray();

            Assert.AreEqual(3, filters.Count());
            Assert.AreEqual("Prop1", filters[0].PropertyName);
            Assert.AreEqual("def", filters[0].Value);
            Assert.AreEqual("Prop2", filters[1].PropertyName);
            Assert.AreEqual("ghi", filters[1].Value);
            Assert.AreEqual("Prop3", filters[2].PropertyName);
            Assert.AreEqual("jkl", filters[2].Value);
        }
        public void TranslateFilterShouldThrowExceptionForOrElseExpression()
        {
            var testVariable = bool.Parse(bool.TrueString);

            FilterFormatters.TranslateFilter <Foo>(f => f.Prop2 == null || testVariable);
        }
        public void TranslateFilterShouldThrowExceptionIfOuterExpressionIsAndAlsoAndInnerRightExpressionIsNotABinaryExpression()
        {
            var testVariable = bool.Parse(bool.TrueString);

            FilterFormatters.TranslateFilter <Foo>(f => f.Prop2 == null && testVariable);
        }