Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
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)));
        }
Ejemplo n.º 4
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)));
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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"));
        }
Ejemplo n.º 8
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));
        }
Ejemplo n.º 9
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)));
        }