Exemplo n.º 1
0
        public void ToString_WithAlias_GeneratesCorrectSQLClause()
        {
            Tables_Blogs table = new Tables_Blogs().As("MyTable");

            var from = new FromClause(table);

            string expected =
                @"FROM
                [dbo].[Blogs] AS [MyTable]
            ";

            Assert.AreEqual(expected, from.ToString());
        }
Exemplo n.º 2
0
        public void ToString_Always_GeneratesCorrectSQLClause()
        {
            var table = new Tables_Blogs();

            var from = new FromClause(table);

            string expected =
                @"FROM
                [dbo].[Blogs]
            ";

            Assert.AreEqual(expected, from.ToString());
        }
Exemplo n.º 3
0
        public void ToString_WithJoin_GeneratesCorrectSQLClause()
        {
            var blogs = new Tables_Blogs();
            var posts = new Tables_Posts();

            FromClause from = new FromClause(blogs).Join(posts, blogs.Id == posts.BlogId);

            string expected =
                @"FROM
                [dbo].[Blogs]
            JOIN		[dbo].[Posts] ON
                    ([dbo].[Blogs].[Id] = [dbo].[Posts].[BlogId])
            ";

            Assert.AreEqual(expected, from.ToString());
        }
Exemplo n.º 4
0
        public void ToString_WithMoreThanOneField_GeneratesCorrectSQLClause()
        {
            var table = new Tables_Blogs();

            var fields = new IFormatableField[]
                         	{
                         		new Tables_Blogs_Id(table),
                         		new Tables_Blogs_Name(table)
                         	};

            var select = new SelectClause(fields);

            string expected =
                @"SELECT
                [dbo].[Blogs].[Id],
                [dbo].[Blogs].[Name]
            ";

            Assert.AreEqual(expected, select.ToString());
        }