Exemple #1
0
        public void OrderBy_ASC()
        {
            //arrange
            SqlConnect sql      = new CSharpedSql.SqlServer.SqlServerConnect();
            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);
        }
Exemple #2
0
        public void Where_Between()
        {
            //arrange
            SqlConnect sql      = new CSharpedSql.SqlServer.SqlServerConnect();
            var        expected = "SELECT * FROM [test] WHERE [id] BETWEEN @item0 AND @item1;";

            //act
            sql.Query(Select.From("test") + Where.Between("id", 3, 6));
            var actual = sql.ToString().TrimEnd();

            //assert
            Assert.AreEqual(expected, actual);
        }
Exemple #3
0
        public void Where_NotEqual()
        {
            //arrange
            SqlConnect sql      = new CSharpedSql.SqlServer.SqlServerConnect();
            var        expected = "SELECT * FROM [test] WHERE [id] <> @item0;";

            //act
            sql.Query(Select.From("test") + Where.NotEqual("id", 5));
            var actual = sql.ToString().TrimEnd();

            //assert
            Assert.AreEqual(expected, actual);
        }
Exemple #4
0
        public void Where_Any()
        {
            //arrange
            SqlConnect sql      = new CSharpedSql.SqlServer.SqlServerConnect();
            var        expected = "SELECT * FROM [test] WHERE [id] = ANY (SELECT * FROM [table]);";

            //act
            sql.Query(Select.From("test") + Where.Any("id", Select.From("table")));
            var actual = sql.ToString().TrimEnd();

            //assert
            Assert.AreEqual(expected, actual);
        }
Exemple #5
0
        public void Where_Or_Where()
        {
            //arrange
            SqlConnect sql      = new CSharpedSql.SqlServer.SqlServerConnect();
            var        expected = "SELECT * FROM [test] WHERE [id] = @item0 OR [name] <> @item1;";

            //act
            sql.Query(Select.From("test") + (Where.Equal("id", 87) | Where.NotEqual("name", "Tim")));
            var actual = sql.ToString().TrimEnd();

            //assert
            Assert.AreEqual(expected, actual);
        }
Exemple #6
0
        public void Where_NotExists()
        {
            //arrange
            SqlConnect sql      = new CSharpedSql.SqlServer.SqlServerConnect();
            var        expected = "SELECT * FROM [test] WHERE NOT EXISTS (SELECT [id] FROM [user] WHERE [id] = @item0);";

            //act
            sql.Query(Select.From("test") + Where.NotExists(Select.From("user", "id") + Where.Equal("id", 7)));
            var actual = sql.ToString().TrimEnd();

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