Exemplo n.º 1
0
        public void MiddleTier_GetTableDataTypes()
        {
            DataTable     table     = WebServiceTests.GetTableDataTypes();
            List <string> strErrors = new List <string>();

            if (table == null || table.Rows == null || table.Columns == null || table.Rows.Count < 1 || table.Rows[0] == null)
            {
                strErrors.Add(table == null?"The DataTable is null.":table.Rows == null?"The DataRowCollection is null.":
                              table.Columns == null?"The DataColumnCollection is null.":table.Rows.Count < 1?"The DataRowCollection is empty.":"The DataRow is null.");
            }
            else
            {
                if (table.Columns.Count < 1 || table.Rows[0][0] == null || table.Rows[0][0].GetType() != typeof(string))
                {
                    strErrors.Add(string.Format("The cell DataType should be {0} but returned {1}.", typeof(string),
                                                table.Columns.Count < 1?"an insufficient column count":table.Rows[0][0] == null?"a null cell":table.Rows[0][0].GetType().ToString()));
                }
                if (table.Columns.Count < 2 || table.Rows[0][1] == null || table.Rows[0][1].GetType() != typeof(decimal))
                {
                    strErrors.Add(string.Format("The cell DataType should be {0} but returned {1}.", typeof(decimal),
                                                table.Columns.Count < 2?"an insufficient column count":table.Rows[0][1] == null?"a null cell":table.Rows[0][1].GetType().ToString()));
                }
                if (table.Columns.Count < 3 || table.Rows[0][2] == null || table.Rows[0][2].GetType() != typeof(DateTime))
                {
                    strErrors.Add(string.Format("The cell DataType should be {0} but returned {1}.", typeof(DateTime),
                                                table.Columns.Count < 3?"an insufficient column count":table.Rows[0][2] == null?"a null cell":table.Rows[0][2].GetType().ToString()));
                }
            }
            Assert.IsTrue(strErrors.Count == 0);
        }