public void Can_Verify_ParentId_StartsWith_Predicate_In_Same_Result()
        {
            //Arrange
            Expression<Func<IContent, bool>> predicate = content => content.ParentId == -1;
            var modelToSqlExpressionHelper = new ModelToSqlExpressionHelper<IContent>();
            var result = modelToSqlExpressionHelper.Visit(predicate);

            Console.WriteLine("Model to Sql ExpressionHelper: \n" + result);

            Assert.AreEqual("[umbracoNode].[parentID] = -1", result);
        }
        public void Equals_Method_For_Value_Gets_Escaped()
        {
            Expression <Func <IUser, bool> > predicate = user => user.Username.Equals("*****@*****.**");
            var modelToSqlExpressionHelper             = new ModelToSqlExpressionHelper <IUser>();
            var result = modelToSqlExpressionHelper.Visit(predicate);

            Console.WriteLine("Model to Sql ExpressionHelper: \n" + result);

            Assert.AreEqual("upper([umbracoUser].[userLogin]) = upper(@0)", result);
            Assert.AreEqual("*****@*****.**", modelToSqlExpressionHelper.GetSqlParameters()[0]);
        }
示例#3
0
        public void Can_Verify_ParentId_StartsWith_Predicate_In_Same_Result()
        {
            //Arrange
            Expression <Func <IContent, bool> > predicate = content => content.ParentId == -1;
            var modelToSqlExpressionHelper = new ModelToSqlExpressionHelper <IContent>();
            var result = modelToSqlExpressionHelper.Visit(predicate);

            Console.WriteLine("Model to Sql ExpressionHelper: \n" + result);

            Assert.AreEqual("[umbracoNode].[parentID] = -1", result);
        }
        public void Can_Verify_Path_StartsWith_Predicate_In_Same_Result()
        {
            //Arrange
            Expression <Func <IContent, bool> > predicate = content => content.Path.StartsWith("-1");
            var modelToSqlExpressionHelper = new ModelToSqlExpressionHelper <IContent>();
            var result = modelToSqlExpressionHelper.Visit(predicate);

            Console.WriteLine("Model to Sql ExpressionHelper: \n" + result);

            Assert.AreEqual("upper([umbracoNode].[path]) LIKE upper(@0)", result);
            Assert.AreEqual("-1%", modelToSqlExpressionHelper.GetSqlParameters()[0]);
        }
        public void Model_Expression_Value_Does_Not_Get_Double_Escaped()
        {
            //mysql escapes backslashes, so we'll test with that
            SqlSyntaxContext.SqlSyntaxProvider = new MySqlSyntaxProvider(Mock.Of <ILogger>());

            Expression <Func <IUser, bool> > predicate = user => user.Username.Equals("mydomain\\myuser");
            var modelToSqlExpressionHelper             = new ModelToSqlExpressionHelper <IUser>();
            var result = modelToSqlExpressionHelper.Visit(predicate);

            Console.WriteLine("Model to Sql ExpressionHelper: \n" + result);

            Assert.AreEqual("upper(`umbracoUser`.`userLogin`) = upper(@0)", result);
            Assert.AreEqual("mydomain\\myuser", modelToSqlExpressionHelper.GetSqlParameters()[0]);
        }