Esempio n. 1
0
        private void CheckGetData(TestCaseResult result,
                                  VirtuosoDataReader dr, int column, Selector selector, Sequence sequence)
        {
            string name        = dr.GetName(column);
            int    tableColumn = checkTable.Columns.IndexOf(name);

            for (int row = 0; dr.Read(); row++)
            {
                //if (dr.IsDBNull (column))
                if (row == 0)
                {
                    continue;
                }

                long length;
                if (selector == Selector.GetBytes)
                {
                    length = dr.GetBytes(column, 0, null, 0, 0);
                }
                else                 //if (selector == Selector.GetChars)
                {
                    length = dr.GetChars(column, 0, null, 0, 0);
                }

                //Console.WriteLine ("row: {0}", row);
                //Console.WriteLine ("length: {0}", length);

                CompareSize(result, row, tableColumn, selector, length, 0);

                long   offset = 0;
                byte[] bytes  = new byte[BufferSize];
                char[] chars  = new char[BufferSize];
                int    count  = 0;
                while (offset < length)
                {
                    //Console.WriteLine ("offset: {0}", offset);

                    long nextLength;
                    if (selector == Selector.GetBytes)
                    {
                        for (int i = 0; i < bytes.Length; i++)
                        {
                            bytes[i] = 0;
                        }
                        nextLength = dr.GetBytes(column, offset, bytes, 0, bytes.Length);
                    }
                    else                     //if (selector == Selector.GetChars)
                    {
                        for (int i = 0; i < chars.Length; i++)
                        {
                            chars[i] = (char)0;
                        }
                        nextLength = dr.GetChars(column, offset, chars, 0, chars.Length);
                    }

                    result.FailIfEqual(this, 0, nextLength);
                    if (offset + nextLength < length)
                    {
                        result.FailIfNotEqual(this, (long)BufferSize, nextLength);
                    }
                    else
                    {
                        result.FailIfNotEqual(this, (long)(length - offset), nextLength);
                    }

                    if (selector == Selector.GetBytes)
                    {
                        CompareData(result, row, tableColumn, bytes, nextLength, offset);
                    }
                    else                     //if (selector == Selector.GetChars)
                    {
                        CompareData(result, row, tableColumn, chars, nextLength, offset);
                    }

                    if (sequence == Sequence.GetAll)
                    {
                        offset += nextLength;
                    }
                    else if (sequence == Sequence.GetHalf)
                    {
                        offset += 2 * nextLength;
                    }
                    else                     //if (sequence == Sequence.GetTwice)
                    {
                        count++;
                        if (count == 2)
                        {
                            count   = 0;
                            offset += 2 * nextLength;
                        }
                    }
                }
            }
        }