public void FormatGremlinFilterShouldReturnEmptyStringForNoCaseSensititiveFilters() { var filters = new List <Filter>(); var baseQuery = new GremlinQuery(null, null, new Dictionary <string, object>(), new List <string>()); var filter = FilterFormatters.FormatGremlinFilter(filters, StringComparison.Ordinal, baseQuery); Assert.AreEqual(string.Empty, filter.FilterText); }
public void FormatGremlinFilterShouldThrowNotSupportedExceptionForExpressionsThatAreNotRegisteredInFilterTypesToCompareNulls() { var filters = new List <Filter> { new Filter { PropertyName = "Foo", Value = null, ExpressionType = ExpressionType.Divide }, }; var baseQuery = new GremlinQuery(null, null, new Dictionary <string, object>(), new List <string>()); FilterFormatters.FormatGremlinFilter(filters, StringComparison.OrdinalIgnoreCase, baseQuery); }
public void FormatGremlinFilterShouldThrowNotSupportedExceptionForCaseInsensitiveEqualFilterOfUnsupportedType() { var filters = new List <Filter> { new Filter { PropertyName = "Foo", Value = new ThreadStaticAttribute(), ExpressionType = ExpressionType.Equal }, }; var baseQuery = new GremlinQuery(null, null, new Dictionary <string, object>(), new List <string>()); FilterFormatters.FormatGremlinFilter(filters, StringComparison.OrdinalIgnoreCase, baseQuery); }
public void FormatGremlinFilterShouldThrowNotSupportedExceptionForExpressionsThatAreNotRegisteredInFilterTypesToCompareNulls() { var filters = new List <Filter> { new Filter { PropertyName = "Foo", Value = null, ExpressionType = ExpressionType.Divide }, }; var baseQuery = new GremlinQuery(null, null, new Dictionary <string, object>(), new List <string>()); var ex = Assert.Throws <NotSupportedException>(() => FilterFormatters.FormatGremlinFilter(filters, StringComparison.OrdinalIgnoreCase, baseQuery)); Assert.AreEqual("One or more of the supplied filters is of an unsupported type or expression. Unsupported filters were: Foo with null value and expression Divide", ex.Message); }
public void FormatGremlinFilterShouldThrowNotSupportedExceptionForCaseInsensitiveEqualFilterOfUnsupportedType() { var filters = new List <Filter> { new Filter { PropertyName = "Foo", Value = new ThreadStaticAttribute(), ExpressionType = ExpressionType.Equal }, }; var baseQuery = new GremlinQuery(null, null, new Dictionary <string, object>(), new List <string>()); var ex = Assert.Throws <NotSupportedException>(() => FilterFormatters.FormatGremlinFilter(filters, StringComparison.OrdinalIgnoreCase, baseQuery)); Assert.AreEqual("One or more of the supplied filters is of an unsupported type or expression. Unsupported filters were: Foo of type System.ThreadStaticAttribute, with expression Equal", ex.Message); }
public void FormatGremlinFilterShouldReturnIteratorSyntaxForSingleCaseInsensititiveEqualFilterWithNullValue() { var filters = new List <Filter> { new Filter { PropertyName = "Foo", Value = null, 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] == null }", filter.FilterText); Assert.AreEqual("Foo", filter.FilterParameters["p0"]); }
public void FormatGremlinFilterShouldReturnIndexerSyntaxForSingleCaseSensititiveEquakFilterWithLongValue() { var filters = new List <Filter> { new Filter { PropertyName = "Foo", Value = (long)123, 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.AreEqual(".filter{ it[p0] == p1 }", filter.FilterText); Assert.AreEqual("Foo", filter.FilterParameters["p0"]); Assert.AreEqual(123, filter.FilterParameters["p1"]); }
public void FormatGremlinFilterShouldReturnIndexerSyntaxForSingleCaseInsensititiveLessThanOrEqualFilterWithLongValue() { var filters = new List <Filter> { new Filter { PropertyName = "Foo", Value = long.MaxValue, ExpressionType = ExpressionType.LessThanOrEqual }, }; 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] <= p1 }", filter.FilterText); Assert.AreEqual("Foo", filter.FilterParameters["p0"]); Assert.AreEqual(9223372036854775807, filter.FilterParameters["p1"]); }
public void FormatGremlinFilterShouldReturnIndexerSyntaxForSingleCaseInsensititiveNotEqualFilterWithEnumValue() { var filters = new List <Filter> { new Filter { PropertyName = "Foo", Value = EnumForTesting.Bar, 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.AreEqual(".filter{ !it[p0].equalsIgnoreCase(p1) }", filter.FilterText); Assert.AreEqual("Foo", filter.FilterParameters["p0"]); Assert.AreEqual("Bar", filter.FilterParameters["p1"]); }
public void FormatGremlinFilterShouldReturnIteratorSyntaxForSingleCaseSensititiveNotEqualFilterZeroLongValue() { var filters = new List <Filter> { new Filter { PropertyName = "Foo", Value = 0L, 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] != p1 }", filter.FilterText); Assert.Equal("Foo", filter.FilterParameters["p0"]); Assert.Equal(0L, filter.FilterParameters["p1"]); }
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()); }
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"]); }