TEST_F(ExpressionOperatorTests, NotEqualOperator_Expression_Constant_ReturnsCorrectPredicate) { Expression<TestExpressionEntity, std::int32_t> expr = ::MakeExpression(&TestExpressionEntity::SetterGetterGetter); Predicate<TestExpressionEntity> setterGetterIsNotEqualToSix = expr != 6; SqlPredicate predicate = setterGetterIsNotEqualToSix.GetSqlPredicate(_registry); EXPECT_EQ(1, predicate.GetNumberOfParameters()); EXPECT_EQ("(TestTable.SetterGetter <> ?)", predicate.GetPredicate()); }
TEST_F(ExpressionOperatorTests, NotEqualToOperator_Expression_null_ReturnsCorrectPredicate) { Expression<TestExpressionEntity, std::int32_t> expr = ::MakeExpression(&TestExpressionEntity::SetterGetterGetter); Predicate<TestExpressionEntity> nullIsNotEqualToSetterGetter = (expr != nullptr); SqlPredicate predicate = nullIsNotEqualToSetterGetter.GetSqlPredicate(_registry); EXPECT_EQ(0, predicate.GetNumberOfParameters()); EXPECT_EQ("(TestTable.SetterGetter IS NOT NULL)", predicate.GetPredicate()); }
TEST_F(ExpressionOperatorTests, EqualOperator_Expression_ConstReferenceGetter_ReturnsCorrectPredicate) { Expression<TestExpressionEntity, std::int32_t> expr = ::MakeExpression(&TestExpressionEntity::SetterGetterGetter); Predicate<TestExpressionEntity> setterGetterIsEqualToSetterConstReferenceGetter = expr == &TestExpressionEntity::SetterConstReferenceGetterGetter; SqlPredicate predicate = setterGetterIsEqualToSetterConstReferenceGetter.GetSqlPredicate(_registry); EXPECT_EQ(0, predicate.GetNumberOfParameters()); EXPECT_EQ("(TestTable.SetterGetter = TestTable.SetterConstReferenceGetter)", predicate.GetPredicate()); }
TEST_F(ExpressionOperatorTests, OrOperator_Exoression_Expression_ReturnsCorrectPredicate) { Expression<TestExpressionEntity, std::int32_t> expr = ::MakeExpression(&TestExpressionEntity::SetterGetterGetter); Predicate<TestExpressionEntity> setterGetterIsEqualToSixAndOrSetterGetterIsNotEqualToFortyTwo = (expr == 6) || (expr != 42); SqlPredicate predicate = setterGetterIsEqualToSixAndOrSetterGetterIsNotEqualToFortyTwo.GetSqlPredicate(_registry); EXPECT_EQ(2, predicate.GetNumberOfParameters()); EXPECT_EQ("((TestTable.SetterGetter = ?) OR (TestTable.SetterGetter <> ?))", predicate.GetPredicate()); }
TEST_F(ExpressionOperatorTests, OrOperator_Constant_Exoression_ReturnsCorrectPredicate) { Expression<TestExpressionEntity, std::int32_t> expr = ::MakeExpression(&TestExpressionEntity::SetterGetterGetter); Predicate<TestExpressionEntity> falsOrSetterGetterIsEqualToSix = false || (expr == 6); SqlPredicate predicate = falsOrSetterGetterIsEqualToSix.GetSqlPredicate(_registry); EXPECT_EQ(2, predicate.GetNumberOfParameters()); EXPECT_EQ("(? OR (TestTable.SetterGetter = ?))", predicate.GetPredicate()); }
TEST_F(ExpressionOperatorTests, OrOperator_Exoression_Constant_ReturnsCorrectPredicate) { Expression<TestExpressionEntity, std::int32_t> expr = ::MakeExpression(&TestExpressionEntity::SetterGetterGetter); Predicate<TestExpressionEntity> setterGetterIsEqualToSixOrTrue = (expr == 6) || true; SqlPredicate predicate = setterGetterIsEqualToSixOrTrue.GetSqlPredicate(_registry); EXPECT_EQ(2, predicate.GetNumberOfParameters()); EXPECT_EQ("((TestTable.SetterGetter = ?) OR ?)", predicate.GetPredicate()); }
TEST_F(ExpressionOperatorTests, GreaterThanOrEqualToOperator_Expression_Field_ReturnsCorrectPredicate) { Expression<TestExpressionEntity, std::int32_t> expr = ::MakeExpression(&TestExpressionEntity::SetterGetterGetter); Predicate<TestExpressionEntity> setterGetterIsGreaterThanOrEqualToField = expr >= &TestExpressionEntity::_field; SqlPredicate predicate = setterGetterIsGreaterThanOrEqualToField.GetSqlPredicate(_registry); EXPECT_EQ(0, predicate.GetNumberOfParameters()); EXPECT_EQ("(TestTable.SetterGetter >= TestTable.Field)", predicate.GetPredicate()); }
TEST_F(ExpressionOperatorTests, GreaterThanOperator_Expression_Getter_ReturnsCorrectPredicate) { Expression<TestExpressionEntity, std::int32_t> expr = ::MakeExpression(&TestExpressionEntity::SetterGetterGetter); Predicate<TestExpressionEntity> setterGetterIsGreaterThanSetterGetter = expr > &TestExpressionEntity::SetterGetterGetter; SqlPredicate predicate = setterGetterIsGreaterThanSetterGetter.GetSqlPredicate(_registry); EXPECT_EQ(0, predicate.GetNumberOfParameters()); EXPECT_EQ("(TestTable.SetterGetter > TestTable.SetterGetter)", predicate.GetPredicate()); }