System.Data.Tests.DataColumnTest.Aggregation_TestForSyntaxErrors C# (CSharp) Method

Aggregation_TestForSyntaxErrors() private method

private Aggregation_TestForSyntaxErrors ( ) : void
return void
        public void Aggregation_TestForSyntaxErrors()
        {
            string error = "Aggregation functions cannot be called on Singular(Parent) Columns";
            DataSet ds = new DataSet();
            DataTable table1 = new DataTable();
            DataTable table2 = new DataTable();
            DataTable table3 = new DataTable();

            table1.Columns.Add("test", typeof(int));
            table2.Columns.Add("test", typeof(int));
            table3.Columns.Add("test", typeof(int));

            ds.Tables.Add(table1);
            ds.Tables.Add(table2);
            ds.Tables.Add(table3);

            DataRelation rel1 = new DataRelation("rel1", table1.Columns[0], table2.Columns[0]);
            DataRelation rel2 = new DataRelation("rel2", table2.Columns[0], table3.Columns[0]);

            ds.Relations.Add(rel1);
            ds.Relations.Add(rel2);

            error = "Aggregation Functions cannot be called on Columns Returning Single Row (Parent Column)";
            try
            {
                table2.Columns.Add("result", typeof(int), "count(parent.test)");
                Assert.False(true);
            }
            catch (SyntaxErrorException)
            {
            }

            error = "Numerical or Functions cannot be called on Columns Returning Multiple Rows (Child Column)";
            // Check arithematic operator
            try
            {
                table2.Columns.Add("result", typeof(int), "10*(child.test)");
                Assert.False(true);
            }
            catch (SyntaxErrorException)
            {
            }

            // Check rel operator
            try
            {
                table2.Columns.Add("result", typeof(int), "(child.test) > 10");
                Assert.False(true);
            }
            catch (SyntaxErrorException)
            {
            }

            // Check predicates 
            try
            {
                table2.Columns.Add("result", typeof(int), "(child.test) IN (1,2,3)");
                Assert.False(true);
            }
            catch (SyntaxErrorException)
            {
            }

            try
            {
                table2.Columns.Add("result", typeof(int), "(child.test) LIKE 1");
                Assert.False(true);
            }
            catch (SyntaxErrorException)
            {
            }

            try
            {
                table2.Columns.Add("result", typeof(int), "(child.test) IS null");
                Assert.False(true);
            }
            catch (SyntaxErrorException)
            {
            }

            // Check Calc Functions
            try
            {
                table2.Columns.Add("result", typeof(int), "isnull(child.test,10)");
                Assert.False(true);
            }
            catch (SyntaxErrorException)
            {
            }
        }