Beispiel #1
0
        public void OrderBy_ASC()
        {
            //arrange
            SqlConnect sql      = new CSharpedSql.MySql.MySqlConnect();
            var        expected = "SELECT * FROM `test` ORDER BY `id` ASC;";

            //act
            sql.Query(Select.From("test") + OrderBy.ASC("id"));
            var actual = sql.ToString().TrimEnd();

            //assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
        public void OrderBy_MultiColumns()
        {
            //arrange
            SqlConnect sql      = new CSharpedSql.SqlServer.SqlServerConnect();
            var        expected = "SELECT * FROM [test] ORDER BY [id], [name], [user] ASC;";

            //act
            sql.Query(Select.From("test") + OrderBy.ASC("id", "name", "user"));
            var actual = sql.ToString().TrimEnd();

            //assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #3
0
        public void Select_From_Where_OrderBy_Join()
        {
            //arrange
            SqlConnect sql      = new CSharpedSql.SqlServer.SqlServerConnect();
            var        expected = "SELECT [test].[hello], [test2].[name] FROM [test] LEFT JOIN [test2] ON [test].[id] = [test2].[name] WHERE [test].[id] = @item0 ORDER BY [test2].[name] ASC;";

            //act
            sql.Query(Select.From("test", "test.hello", "test2.name") + Where.Equal("test.id", 2) + Join.Left("test", "id", "test2", "name") + OrderBy.ASC("test2.name"));
            var actual = sql.ToString().TrimEnd();

            //assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #4
0
        public void Select_From_Where_OrderBy_Join()
        {
            //arrange
            SqlConnect sql      = new CSharpedSql.MySql.MySqlConnect();
            var        expected = "SELECT `test`.`hello`, `test2`.`name` FROM `test` LEFT JOIN `test2` ON `test`.`id` = `test2`.`name` WHERE `test`.`id` = @item0 ORDER BY `test2`.`name` ASC;";

            //act
            sql.Query(Select.From("test", "test.hello", "test2.name") + Where.Equal("test.id", 2) + Join.Left("test", "id", "test2", "name") + OrderBy.ASC("test2.name"));
            var actual = sql.ToString().TrimEnd();

            //assert
            Assert.AreEqual(expected, actual);
        }