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); }
/// <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); }
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))); }
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))); }
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)); }
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); }
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 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)); }
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))); }