Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added unit tests for CypherWhereExpressionVisitor.VisitConstantMember()

The unit tests from the last commit was moved from the
CypherFluentQueryWhereTests to CypherWhereExpressionBuilderTests and added
three more unit tests for all logic branches within this method.
  • Loading branch information...
commit 1726e714213a66bf85c5375869e4a1285cba35d3 1 parent 38868f3
@arturosevilla arturosevilla authored
View
15 Test/Cypher/CypherFluentQueryWhereTests.cs
@@ -34,21 +34,6 @@ public void ComparePropertiesAcrossEntitiesEqual()
}
[Test]
- public void CompareWithNullInMemberExpression()
- {
- var client = Substitute.For<IRawGraphClient>();
- var mockWithNullField = new MockWithNullField
- {
- NullField = null
- };
- var query = new CypherFluentQuery(client)
- .Where<MockWithNullField>(a => a.NullField == mockWithNullField.NullField)
- .Query;
-
- Assert.AreEqual("WHERE (not(has(a.NullField)))", query.QueryText);
- }
-
- [Test]
public void ComparePropertiesAcrossEntitiesNotEqual()
{
var client = Substitute.For<IRawGraphClient>();
View
60 Test/Cypher/CypherWhereExpressionBuilderTests.cs
@@ -159,6 +159,66 @@ public void ForPre20VersionsEvaluateFalseWhenComparingMissingNullablePropertyLes
}
[Test]
+ public void ForPre20VersionsEvaluateTrueWhenComparingMissingNullablePropertyToNullProperty()
+ {
+ 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.Cypher19);
+
+ Assert.AreEqual("(foo.NullableBar? is null)", result);
+ }
+
+ [Test]
+ public void For20VersionsEvaluateTrueWhenComparingMissingNullablePropertyToNullProperty()
+ {
+ 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.AreEqual("(not(has(foo.NullableBar)))", result);
+ }
+
+ [Test]
+ public void ForPre20VersionsEvaluateTrueWhenComparingNotMissingNullablePropertyToNullProperty()
+ {
+ 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.Cypher19);
+
+ Assert.AreEqual("(foo.NullableBar? is not null)", result);
+ }
+
+ [Test]
+ 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.AreEqual("(has(foo.NullableBar))", result);
+ }
+
+ [Test]
public void ForPre20VersionsEvaluateTrueWhenComparingMissingNullablePropertyToNull()
{
var parameters = new Dictionary<string, object>();

0 comments on commit 1726e71

Please sign in to comment.
Something went wrong with that request. Please try again.