Пример #1
0
        public void Clear()
        {
            DataTableCollection tbcol = _dataset[0].Tables;

            tbcol.Add(_tables[0]);
            tbcol.Clear();
            Assert.Equal(0, tbcol.Count);

            tbcol.AddRange(new DataTable[] { _tables[0], _tables[1] });
            tbcol.Clear();
            Assert.Equal(0, tbcol.Count);
        }
Пример #2
0
        public void Contains()
        {
            DataTableCollection tbcol = _dataset[0].Tables;

            tbcol.Clear();
            /* _tables is array of DataTables defined in Setup */
            tbcol.AddRange(_tables);
            string tblname = "";

            /* checking for a recently input table, expecting true */
            Assert.Equal(true, tbcol.Contains(_tables[0].TableName));
            /* trying to check with a empty string, expecting false */
            Assert.Equal(false, tbcol.Contains(tblname));
            /* trying to check for a table that donot exist, expecting false */
            Assert.Equal(false, tbcol.Contains("InvalidTableName"));
        }
Пример #3
0
        public void CanRemove()
        {
            DataTableCollection tbcol = _dataset[0].Tables;

            tbcol.Clear();
            /* _tables is array of DataTables defined in Setup */
            tbcol.AddRange(_tables);
            DataTable tbl = null;

            /* checking for a recently input table, expecting true */
            Assert.Equal(true, tbcol.CanRemove(_tables[0]));
            /* trying to check with a null reference, expecting false */
            Assert.Equal(false, tbcol.CanRemove(tbl));
            /* trying to check with a table that does not exist in collection, expecting false */
            Assert.Equal(false, tbcol.CanRemove(new DataTable("newTable")));
        }
Пример #4
0
        public void Remove()
        {
            DataTableCollection tbcol = _dataset[0].Tables;

            tbcol.Clear();
            /* _tables is array of DataTables defined in Setup */
            tbcol.AddRange(_tables);

            /* removing a recently added table */
            int count = tbcol.Count;

            tbcol.Remove(_tables[0]);
            Assert.Equal(count - 1, tbcol.Count);
            DataTable tbl = null;

            /* removing a null reference. must generate an Exception */
            Assert.Throws <ArgumentNullException>(() => tbcol.Remove(tbl));
            /* removing a table that is not there in collection */
            Assert.Throws <ArgumentException>(() => tbcol.Remove(new DataTable("newTable")));
        }
Пример #5
0
        public void AddRange()
        {
            DataTableCollection tbcol = _dataset[0].Tables;

            tbcol.Clear();
            /* _tables is array of type DataTable defined in Setup */
            tbcol.AddRange(_tables);
            int i, j;

            i = 0;
            foreach (DataTable table in tbcol)
            {
                Assert.Equal(_tables[i].TableName, table.TableName);
                j = 0;
                foreach (DataColumn column in table.Columns)
                {
                    Assert.Equal(_tables[i].Columns[j].ColumnName, column.ColumnName);
                    j++;
                }
                i++;
            }
        }
Пример #6
0
        public void Remove()
        {
            DataTableCollection tbcol = _dataset[0].Tables;

            tbcol.Clear();
            /* _tables is array of DataTables defined in Setup */
            tbcol.AddRange(_tables);

            /* removing a recently added table */
            int count = tbcol.Count;

            tbcol.Remove(_tables[0]);
            Assert.Equal(count - 1, tbcol.Count);
            DataTable tbl = null;

            /* removing a null reference. must generate an Exception */
            try
            {
                tbcol.Remove(tbl);
                Assert.False(true);
            }
            catch (Exception e)
            {
                Assert.Equal(typeof(ArgumentNullException), e.GetType());
            }
            /* removing a table that is not there in collection */
            try
            {
                tbcol.Remove(new DataTable("newTable"));
                Assert.False(true);
            }
            catch (Exception e)
            {
                Assert.Equal(typeof(ArgumentException), e.GetType());
            }
        }