//[Description("https://bitbucket.org/Readify/neo4jclient/issue/163/neo4j-v2m6-client-syntax-error")]
        public void For20DontSuffixPropertyWhenComparingMissingNullablePropertyToNotNull()
        {
            var parameters = new Dictionary <string, object>();
            Expression <Func <Foo, bool> > expression = foo => foo.NullableBar != null;

            var result = CypherWhereExpressionBuilder.BuildText(expression, v => CreateParameter(parameters, v), CypherCapabilities.Cypher20);

            Assert.Equal("(has(foo.NullableBar))", result);
        }
        public void ForPre20VersionsEvaluateFalseWhenComparingMissingNullablePropertyToNotNull()
        {
            var parameters = new Dictionary <string, object>();
            Expression <Func <Foo, bool> > expression = foo => foo.NullableBar != null;

            var result = CypherWhereExpressionBuilder.BuildText(expression, v => CreateParameter(parameters, v), CypherCapabilities.Cypher19);

            Assert.Equal("(foo.NullableBar? is not null)", result);
        }
        public void AccessStaticProperty()
        {
            var parameters = new Dictionary <string, object>();
            Expression <Func <Foo, bool> > expression = foo => foo.Bar == BazProperty;

            var result = CypherWhereExpressionBuilder.BuildText(expression, v => CreateParameter(parameters, v));

            Assert.Equal("(foo.Bar = {p0})", result);
            Assert.Equal(456, parameters["p0"]);
        }
        static void TestShouldComparePropertiesAcrossInterfacesViaGenerics <TNode>() where TNode : IFoo
        {
            var parameters = new Dictionary <string, object>();
            Expression <Func <TNode, TNode, bool> > expression =
                (p1, p2) => p1.Bar == p2.Bar;

            var result = CypherWhereExpressionBuilder.BuildText(expression, v => CreateParameter(parameters, v));

            Assert.Equal("(p1.Bar = p2.Bar)", result);
        }
        //[Description("https://bitbucket.org/Readify/neo4jclient/issue/163/neo4j-v2m6-client-syntax-error")]
        public void DontSuffixPropertyWhenComparingMissingNullablePropertyLessThanOrEqualToConstantValue()
        {
            var parameters = new Dictionary <string, object>();
            Expression <Func <Foo, bool> > expression = foo => foo.NullableBar <= 123;

            var result = CypherWhereExpressionBuilder.BuildText(expression, v => CreateParameter(parameters, v));

            Assert.Equal("(foo.NullableBar <= {p0})", result);
            Assert.Equal(123, parameters["p0"]);
        }
        //[Description("https://bitbucket.org/Readify/neo4jclient/issue/103/cypher-queries-include-nodes-with-missing")]
        public void ForPre20VersionsEvaluateFalseWhenComparingMissingNullablePropertyLessThanOrEqualToConstantValue()
        {
            var parameters = new Dictionary <string, object>();
            Expression <Func <Foo, bool> > expression = foo => foo.NullableBar <= 123;

            var result = CypherWhereExpressionBuilder.BuildText(expression, v => CreateParameter(parameters, v), CypherCapabilities.Cypher19);

            Assert.Equal("(foo.NullableBar! <= {p0})", result);
            Assert.Equal(123, parameters["p0"]);
        }
        //[Description("https://bitbucket.org/Readify/neo4jclient/issue/99/throw-error-when-unary-expressions-are")]
        public void ThrowNotSupportedExceptionForUnaryNotExpression()
        {
            // Where<FooData>(n => !n.Bar)

            var parameters = new Dictionary <string, object>();
            Expression <Func <Foo, bool> > expression =
                p1 => !p1.SomeBool;

            Assert.Throws <NotSupportedException>(() =>
                                                  CypherWhereExpressionBuilder.BuildText(expression, v => CreateParameter(parameters, v)));
        }
        //[Description("https://bitbucket.org/Readify/neo4jclient/issue/163/neo4j-v2m6-client-syntax-error")]
        public void DontSuffixPropertyWhenComparingMissingNullablePropertyLessThanLocalMemberValue()
        {
            var localObject = new { NoneCypherLocalProperty = 123 };
            var parameters  = new Dictionary <string, object>();
            Expression <Func <Foo, bool> > expression = foo => foo.NullableBar < localObject.NoneCypherLocalProperty;

            var result = CypherWhereExpressionBuilder.BuildText(expression, v => CreateParameter(parameters, v));

            Assert.Equal("(foo.NullableBar < {p0})", result);
            Assert.Equal(123, parameters["p0"]);
        }
        //[Description("https://bitbucket.org/Readify/neo4jclient/issue/98/where-andwhere-include-nodes-with-missing")]
        public void ForPre20VersionsEvaluateFalseWhenComparingMissingNullablePropertyGreaterThanOrEqualToLocalMemberValue()
        {
            var localObject = new { NoneCypherLocalProperty = 123 };
            var parameters  = new Dictionary <string, object>();
            Expression <Func <Foo, bool> > expression = foo => foo.NullableBar >= localObject.NoneCypherLocalProperty;

            var result = CypherWhereExpressionBuilder.BuildText(expression, v => CreateParameter(parameters, v), CypherCapabilities.Cypher19);

            Assert.Equal("(foo.NullableBar! >= {p0})", result);
            Assert.Equal(123, parameters["p0"]);
        }
        //[Description("https://bitbucket.org/Readify/neo4jclient/issue/158/neo4jclient-cypher-where-clauses-using-a")]
        public void ShouldCompareAgainstValueOfNullableType()
        {
            var bar = (long?)123;

            var parameters = new Dictionary <string, object>();
            Expression <Func <Foo, bool> > expression = foo => foo.Bar == bar.Value;

            var result = CypherWhereExpressionBuilder.BuildText(expression, v => CreateParameter(parameters, v));

            Assert.Equal("(foo.Bar = {p0})", result);
            Assert.Equal(123L, parameters["p0"]);
        }
        public void ShouldComparePropertiesAcrossInterfaces()
        {
            // http://stackoverflow.com/questions/15718916/neo4jclient-where-clause-not-putting-in-parameters
            // Where<TSourceNode, TSourceNode>((otherStartNodes, startNode) => otherStartNodes.Id != startNode.Id)

            var parameters = new Dictionary <string, object>();
            Expression <Func <IFoo, IFoo, bool> > expression =
                (p1, p2) => p1.Bar == p2.Bar;

            var result = CypherWhereExpressionBuilder.BuildText(expression, v => CreateParameter(parameters, v));

            Assert.Equal("(p1.Bar = p2.Bar)", result);
        }
        public void For20VersionsEvaluateTrueWhenComparingNotMissingNullablePropertyToNullProperty()
        {
            var parameters   = new Dictionary <string, object>();
            var fooWithNulls = new Foo
            {
                NullableBar = null
            };
            Expression <Func <Foo, bool> > expression = foo => foo.NullableBar != fooWithNulls.NullableBar;

            var result = CypherWhereExpressionBuilder.BuildText(expression, v => CreateParameter(parameters, v), CypherCapabilities.Cypher20);

            Assert.Equal("(has(foo.NullableBar))", result);
        }
        public void GetsValueFromNestedProperty()
        {
            var comparison = new Nested {
                Foo = new Foo {
                    Bar = BazField
                }
            };

            var parameters = new Dictionary <string, object>();
            Expression <Func <Foo, bool> > expression = foo => foo.Bar == comparison.Foo.Bar;

            var result = CypherWhereExpressionBuilder.BuildText(expression, v => CreateParameter(parameters, v));

            Assert.Equal("(foo.Bar = {p0})", result);
            Assert.Equal(123, parameters["p0"]);
        }