Пример #1
0
		public void DoTestTypes(DbTypeParametersCollection row)
		{
			testTypesInvocations++;
			exp = null;
			string rowId = "43969_" + 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 double.
					for (int i=0; i<row.Count; i++)
					{
						if (row[i].Value.GetType() == typeof(double) ||
							row[i].Value.GetType() == typeof(decimal)) //The value in the result set should be a double.
						{
							try
							{
								BeginCase(string.Format("Calling GetDouble() on a field of dbtype {0}", row[i].DbTypeName));
								double retDouble = rdr.GetDouble(i);
								Compare(row[i].Value, retDouble);
							}
							catch (Exception ex)
							{
								exp = ex;
							}
							finally
							{
								EndCase(exp);
								exp = null;
							}
						}
						else //The value in the result set should NOT be double. In this case an Invalid case exception should be thrown.
						{
							try
							{
								BeginCase(string.Format("Calling GetDouble() on a field of dbtype {0}", row[i].DbTypeName));
								double retDouble = rdr.GetDouble(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();
			}
		}
	}
Пример #3
0
		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();
				}
				
			}
		}
		public void DoTestTypes(DbTypeParametersCollection row)
		{
			testTypesInvocations++;
			exp = null;
			string rowId = "43966_" + this.testTypesInvocations.ToString();
				OleDbConnection con =null;
				OleDbDataReader 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();
				}
			}
		}
Пример #5
0
		private void TypesTests(DbTypeParametersCollection typesToTest)
		{
			exp = null;

			DbTypeParametersCollection currentlyTested = new DbTypeParametersCollection(typesToTest.TableName);
			string rowId = "13289";
			object dbValue;
			OleDbDataReader rdr = null;
			OleDbConnection 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
				{
					if (rdr != null && !rdr.IsClosed)
					{
						rdr.Close();
					}
					if (selectCon != null && selectCon.State != ConnectionState.Closed)
					{
						selectCon.Close();
					}
					currentlyTested.ExecuteDelete(rowId);
					EndCase(exp);
					exp = null;
				}
			}
		}