public void TestHasRowsFalse() { BeginCase("Test HasRows = False"); exp = null; string rowId = string.Format("43977_{0}", TestCaseNumber); OracleConnection con = null; OracleDataReader rdr = null; try { DbTypeParametersCollection row = ConnectedDataProvider.GetSimpleDbTypesParameters(); row.ExecuteDelete(rowId); //Make sure that a row with such ID does not exist. row.ExecuteSelectReader(rowId, out rdr, out con); Compare(rdr.HasRows, false); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; } }
public void TestHasRowsTrue() { BeginCase("Test HasRows = True"); exp = null; string rowId = string.Format("43977_{0}", TestCaseNumber); OracleConnection con = null; OracleDataReader rdr = null; try { DbTypeParametersCollection row = ConnectedDataProvider.GetSimpleDbTypesParameters(); row.ExecuteInsert(rowId); row.ExecuteSelectReader(rowId, out rdr, out con); Compare(rdr.HasRows, true); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; } }
private void TypesTests(DbTypeParametersCollection typesToTest) { exp = null; DbTypeParametersCollection currentlyTested = new DbTypeParametersCollection(typesToTest.TableName); string rowId = "13289"; object dbValue; OracleDataReader rdr = null; OracleConnection selectCon = null; DataBaseServer testedDbServer = ConnectedDataProvider.GetDbType(); foreach (DbTypeParameter currentParamType in typesToTest) { BeginCase("Test value of db type: " + currentParamType.DbTypeName); //Prepare data: rowId = string.Format("13289_{0}", this.TestCaseNumber); currentlyTested.Clear(); currentlyTested.Add(currentParamType); currentlyTested.ExecuteInsert(rowId); try { currentlyTested.ExecuteSelectReader(rowId, out rdr, out selectCon); rdr.Read(); dbValue = WorkaroundOracleCharsPaddingLimitation(testedDbServer, currentParamType, rdr.GetValue(0)); if (currentParamType.Value.GetType().IsArray) { Compare(dbValue as Array, currentParamType.Value as Array); } else { Compare(dbValue, currentParamType.Value); } } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; if (rdr != null && !rdr.IsClosed) { rdr.Close(); } if (selectCon != null && selectCon.State != ConnectionState.Closed) { selectCon.Close(); } currentlyTested.ExecuteDelete(rowId); } } }
public void TestUsingParametersArray() { //Only apply to MSSQL if ((ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer)) { return; } Exception exp = null; OracleDataReader rdr = null; OracleConnection con = null; DbTypeParametersCollection row = new DbTypeParametersCollection(GUID_TABLE_NAME); string rowId = string.Empty; try { BeginCase("Test using parameters array"); rowId = "43973_" + TestCaseNumber.ToString(); row.Add("UNIQUEIDENTIFIER", new Guid(TEST_GUID_STRING)); row.ExecuteInsert(rowId); row.ExecuteSelectReader(rowId, out rdr, out con); rdr.Read(); Guid guidValue = rdr.GetGuid(0); Compare(guidValue, row[GUID_COLUMN_NAME].Value); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; if ((rdr != null) && (!rdr.IsClosed)) { rdr.Close(); } if (rowId != String.Empty) { row.ExecuteDelete(rowId); } if ((con != null) && (con.State != ConnectionState.Closed)) { con.Close(); } } }
private void ValueInColumn(string columnToTest, string valueToTest) { exp = null; OracleDataReader rdr = null; OracleConnection con = null; DbTypeParametersCollection row = ConnectedDataProvider.GetSimpleDbTypesParameters(); BeginCase(string.Format("Use {0} as value", valueToTest)); string rowId = TEST_CASE_ID + TestCaseNumber.ToString(); try { foreach (DbTypeParameter param in row) { param.Value = DBNull.Value; } row[columnToTest].Value = valueToTest; Log("rowId:" + rowId + " columnToTest:" + columnToTest + " valueToTest:" + valueToTest); row.ExecuteInsert(rowId); row.ExecuteSelectReader(rowId, out rdr, out con); rdr.Read(); int columnOrdinal = rdr.GetOrdinal(columnToTest); //this.Log(valueToTest); Compare(valueToTest, rdr.GetValue(columnOrdinal)); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); if (rdr != null && !rdr.IsClosed) { rdr.Close(); } row.ExecuteDelete(rowId); if (con != null && con.State != ConnectionState.Closed) { con.Close(); } } }
public void DoTestTypes(DbTypeParametersCollection row) { testTypesInvocations++; exp = null; string rowId = "43968_" + this.testTypesInvocations.ToString(); OracleDataReader rdr = null; OracleConnection con = null; try { row.ExecuteInsert(rowId); row.ExecuteSelectReader(rowId, out rdr, out con); while (rdr.Read()) { //Run over all the columns in the result set row. //For each column, try to read it as a Decimal. for (int i = 0; i < row.Count; i++) { if (row[i].Value.GetType() == typeof(decimal) || row[i].Value.GetType() == typeof(double)) //The value in the result set should be a Decimal. { try { BeginCase(string.Format("Calling GetDecimal() on a field of dbtype {0}", row[i].DbTypeName)); decimal retDecimal = rdr.GetDecimal(i); Compare(row[i].Value, retDecimal); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; } } else //The value in the result set should NOT be Decimal. In this case an Invalid case exception should be thrown. { try { BeginCase(string.Format("Calling GetDecimal() on a field of dbtype {0}", row[i].DbTypeName)); decimal retDecimal = rdr.GetDecimal(i); ExpectedExceptionNotCaught("InvalidCastException"); } catch (InvalidCastException ex) { ExpectedExceptionCaught(ex); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; } } } } } finally { row.ExecuteDelete(rowId); if ((rdr != null) && (!rdr.IsClosed)) { rdr.Close(); } if ((con != null) && (con.State != ConnectionState.Closed)) { con.Close(); } } }
public void DoTestTextualFieldsThatContainNumbers(DbTypeParametersCollection row) { //Leave only textual fields in the collection, and set their value to the string "10" SetTextualFieldsWithNumericValues(ref row); if (row.Count < 1) { return; } testTypesInvocations++; exp = null; string rowId = "43968_" + this.testTypesInvocations.ToString(); OracleDataReader rdr = null; OracleConnection con = null; try { row.ExecuteInsert(rowId); row.ExecuteSelectReader(rowId, out rdr, out con); while (rdr.Read()) { //Run over all the columns in the result set row. //For each column, try to read it as a Decimal. //Because all the fields are textual, this should throw an InvalidCastException. for (int i = 0; i < row.Count; i++) { try { BeginCase(string.Format("Calling GetDecimal() on a textual field of dbtype {0} with value '{1}'", row[i].DbTypeName, row[i].Value)); decimal retDecimal = rdr.GetDecimal(i); ExpectedExceptionNotCaught(typeof(InvalidCastException).FullName); } catch (InvalidCastException ex) { ExpectedExceptionCaught(ex); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; } } } } finally { row.ExecuteDelete(rowId); if ((rdr != null) && (!rdr.IsClosed)) { rdr.Close(); } if ((con != null) && (con.State != ConnectionState.Closed)) { con.Close(); } } }
public void DoTestTypes(DbTypeParametersCollection row) { testTypesInvocations++; exp = null; string rowId = "43966_" + this.testTypesInvocations.ToString(); OracleConnection con = null; OracleDataReader rdr = null; try { row.ExecuteInsert(rowId); row.ExecuteSelectReader(rowId, out rdr, out con); while (rdr.Read()) { //Run over all the columns in the result set row. //For each column, try to read it as a byte array. for (int i = 0; i < row.Count; i++) { if (row[i].Value.GetType() == typeof(byte[])) //The value in the result set should be a byte array. { try { BeginCase(string.Format("Calling GetBytes() on a field of dbtype {0}", row[i].DbTypeName)); byte[] origBytes = (byte[])row[i].Value; byte[] retBytes = new byte[origBytes.Length]; rdr.GetBytes(i, 0, retBytes, 0, origBytes.Length); Compare(origBytes, retBytes); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; } } else //The value in the result set should NOT be byte array. In this case an Invalid case exception should be thrown. { try { BeginCase(string.Format("Calling GetBytes() on a field of dbtype {0}", row[i].DbTypeName)); byte[] retBytes = new byte[1]; rdr.GetBytes(i, 0, retBytes, 0, 1); ExpectedExceptionNotCaught("InvalidCastException"); } catch (InvalidCastException ex) { ExpectedExceptionCaught(ex); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; } } } } } finally { row.ExecuteDelete(rowId); if (rdr != null && !rdr.IsClosed) { rdr.Close(); } if (con != null && con.State != ConnectionState.Closed) { con.Close(); } } }