System.Data.Tests.DataViewTest2.RowFilter C# (CSharp) Method

RowFilter() private method

private RowFilter ( ) : void
return void
        public void RowFilter()
        {
            //note: this test does not check all the possible row filter expression. this is done in DataTable.Select method.
            // this test also check DataView.Count property

            DataRowView[] drvResult = null;
            ArrayList al = new ArrayList();

            //create the source datatable
            DataTable dt = DataProvider.CreateChildDataTable();

            //create the dataview for the table
            DataView dv = new DataView(dt);

            //-------------------------------------------------------------
            //Get excpected result 
            al.Clear();
            foreach (DataRow dr in dt.Rows)
            {
                if ((int)dr["ChildId"] == 1)
                {
                    al.Add(dr);
                }
            }

            // RowFilter = 'ChildId=1', check count
            dv.RowFilter = "ChildId=1";
            Assert.Equal(al.Count, dv.Count);

            // RowFilter = 'ChildId=1', check rows
            drvResult = new DataRowView[dv.Count];
            dv.CopyTo(drvResult, 0);
            //check that the filterd rows exists
            bool Succeed = true;
            for (int i = 0; i < drvResult.Length; i++)
            {
                Succeed = al.Contains(drvResult[i].Row);
                if (!Succeed) break;
            }
            Assert.Equal(true, Succeed);
            //-------------------------------------------------------------

            //-------------------------------------------------------------
            //Get excpected result 
            al.Clear();
            foreach (DataRow dr in dt.Rows)
                if ((int)dr["ChildId"] == 1 && dr["String1"].ToString() == "1-String1")
                    al.Add(dr);

            // RowFilter - ChildId=1 and String1='1-String1'
            dv.RowFilter = "ChildId=1 and String1='1-String1'";
            Assert.Equal(al.Count, dv.Count);

            // RowFilter = ChildId=1 and String1='1-String1', check rows
            drvResult = new DataRowView[dv.Count];
            dv.CopyTo(drvResult, 0);
            //check that the filterd rows exists
            Succeed = true;
            for (int i = 0; i < drvResult.Length; i++)
            {
                Succeed = al.Contains(drvResult[i].Row);
                if (!Succeed) break;
            }
            Assert.Equal(true, Succeed);
            //-------------------------------------------------------------

            //EvaluateException
            // RowFilter - check EvaluateException
            Assert.Throws<EvaluateException>(() =>
            {
                dv.RowFilter = "Col=1";
            });

            //SyntaxErrorException 1
            // RowFilter - check SyntaxErrorException 1
            Assert.Throws<SyntaxErrorException>(() =>
            {
                dv.RowFilter = "sum('something')";
            });

            //SyntaxErrorException 2
            // RowFilter - check SyntaxErrorException 2
            Assert.Throws<SyntaxErrorException>(() =>
            {
                dv.RowFilter = "HH**!";
            });
        }