Example #1
0
        public void GetByOrdinal()
        {
            var header = new RowHeader
            {
                HasRows = true,
                Names   = new List <string> {
                    "cola", "colb"
                },
                Types = new List <int> {
                    (int)FieldType.Object, (int)FieldType.String
                }
            };

            var f = ValidField;
            var r = new RowInformation(header);

            r.Add(new ColumnInformation(f, 0, "cola", false));
            r.Add(new ColumnInformation(ValidField, 1, "colb", false));

            var c = r.Get(0);

            Assert.AreEqual(c.Ordinal, 0);
            Assert.AreEqual(c.Name, "cola");
            Assert.AreEqual(f.Name, c.Field.Name);
            Assert.AreEqual(f.Type, c.Field.Type);
        }
Example #2
0
        /// <summary>
        /// Get the current row or go and fetch it.
        /// </summary>
        /// <returns></returns>
        private RowInformation GetRow()
        {
            // do we already have the information?
            if (null != _currentRowInformation)
            {
                return(_currentRowInformation);
            }

            if (null == _currentRowHeader)
            {
                throw new SQLiteServerException("Missing row headers.");
            }

            // get the row.
            var row = GetGuiOnlyValueAsync <RowData>(SQLiteMessage.ExecuteReaderGetRowRequest).Result;

            _currentRowInformation = new RowInformation(_currentRowHeader);
            var ordinal = 0;

            for (var i = 0; i < row.Columns.Count; ++i)
            {
                var column = row.Columns[i];
                var isNull = row.Nulls[i];
                _currentRowInformation.Add(new ColumnInformation(column, ordinal++, column.Name, isNull));
            }
            return(_currentRowInformation);
        }
Example #3
0
        public TableRowProvider(AutomationProvider parent, RowInformation rowInformation)
            : base(parent, SelectionItemPattern.Pattern)
        {
            _rowInformation = rowInformation;
            Name            = rowInformation.Value;
            ControlType     = ControlType.DataItem;

            rowInformation.Cells.ForEach(x => AddChild(new TableCellProvider(this, x)));

            SetPropertyValue(AutomationElementIdentifiers.IsOffscreenProperty.Id, () => !rowInformation.IsVisible);
        }
Example #4
0
        /// <inheritdoc />
        public async Task <bool> ReadAsync(CancellationToken cancellationToken)
        {
            var rowHeader = await GetGuiOnlyValueAsync <RowHeader>(SQLiteMessage.ExecuteReaderReadRequest).ConfigureAwait(false);

            _currentRowHeader   = rowHeader;
            _parentCommand.Guid = _currentRowHeader.Guid;

            // we need to reset some field now.
            _dataTypeName.Clear();
            _currentRowInformation = null;

            // if we have no rows, then we have nothing else to read.
            return(rowHeader.HasRows);
        }
Example #5
0
        public void CannotAddNullColumn()
        {
            var header = new RowHeader
            {
                HasRows = true,
                Names   = new List <string> {
                    "cola"
                },
                Types = new List <int> {
                    (int)FieldType.Object
                }
            };

            var r = new RowInformation(header);

            Assert.Throws <ArgumentNullException>(() => r.Add(null));
        }
Example #6
0
        public void OrdinalDoesNotMatchTheName()
        {
            var header = new RowHeader
            {
                HasRows = true,
                Names   = new List <string> {
                    "cola", "colb", "colc"
                },
                Types = new List <int> {
                    (int)FieldType.Object, (int)FieldType.String, (int)FieldType.Double
                }
            };

            var r = new RowInformation(header);

            Assert.Throws <ArgumentException>(() => r.Add(new ColumnInformation(ValidField, 0, "colb", false)));
        }
Example #7
0
        public void AddingAColumnOrdinalThatDoesNotExist()
        {
            var header = new RowHeader
            {
                HasRows = true,
                Names   = new List <string> {
                    "cola", "colb"
                },
                Types = new List <int> {
                    (int)FieldType.Object, (int)FieldType.String
                }
            };

            var r = new RowInformation(header);

            r.Add(new ColumnInformation(ValidField, 0, "cola", false));
            Assert.Throws <ArgumentException>(() => r.Add(new ColumnInformation(ValidField, 3, "colb", false)));
        }
Example #8
0
        public void CannotAddSameName()
        {
            var header = new RowHeader
            {
                HasRows = true,
                Names   = new List <string> {
                    "cola", "colb", "colc"
                },
                Types = new List <int> {
                    (int)FieldType.Object, (int)FieldType.String, (int)FieldType.Double
                }
            };

            var r = new RowInformation(header);

            r.Add(new ColumnInformation(ValidField, 0, "cola", false));
            r.Add(new ColumnInformation(ValidField, 1, "colb", false));
            Assert.Throws <DuplicateNameException>(() => r.Add(new ColumnInformation(ValidField, 2, "cola", false)));
        }
Example #9
0
        public void TryingToGetByOrdinalThatDoesNotExist()
        {
            var header = new RowHeader
            {
                HasRows = true,
                Names   = new List <string> {
                    "cola", "colb"
                },
                Types = new List <int> {
                    (int)FieldType.Object, (int)FieldType.String
                }
            };

            var r = new RowInformation(header);

            r.Add(new ColumnInformation(ValidField, 0, "cola", false));
            r.Add(new ColumnInformation(ValidField, 1, "colb", false));

            Assert.Throws <IndexOutOfRangeException>(() => r.Get(2));
        }
Example #10
0
        public void CheckNullValue()
        {
            var header = new RowHeader
            {
                HasRows = true,
                Names   = new List <string> {
                    "cola", "colb"
                },
                Types = new List <int> {
                    (int)FieldType.Object, (int)FieldType.String
                }
            };

            var f = ValidField;
            var r = new RowInformation(header);

            r.Add(new ColumnInformation(f, 0, "cola", true));
            r.Add(new ColumnInformation(ValidField, 1, "colb", false));

            Assert.IsTrue(r.Get(0).IsNull);
            Assert.IsFalse(r.Get(1).IsNull);
        }
Example #11
0
        public void GetByNameCaseInsensitive()
        {
            var header = new RowHeader
            {
                HasRows = true,
                Names   = new List <string> {
                    "cola", "colb", "colc"
                },
                Types = new List <int> {
                    (int)FieldType.Object, (int)FieldType.String, (int)FieldType.Double
                }
            };

            var f = ValidField;
            var r = new RowInformation(header);

            r.Add(new ColumnInformation(f, 0, "cola", false));
            r.Add(new ColumnInformation(ValidField, 1, "colb", false));

            Assert.IsNotNull(r.Get("cola"));
            Assert.IsNotNull(r.Get("COLA"));
            Assert.IsNotNull(r.Get("ColA"));
        }
        public void SetUp()
        {
            SetupTheTable();

            _rowInformation = DataGridRowInformation.FromRow(_dataGridRow);
        }