public void ToSingleOrDefaultRow_SingleOrDefaultRow_Works() { var resultSet = new ResultSet() { Columns = new List<Column>() { new Column("Value") }, Rows = new List<Row>() { new Row(new List<object>() { 18 }) } }; var converter = new MultipleResultSetConverter(new List<ResultSet>() { resultSet }); Assert.AreEqual(18, converter.ToSingleOrDefaultRow<ScalarTestModel>().Value); }
public void ToScalar_IsValid_Works() { var resultSet = new ResultSet() { Columns = new List<Column>() { new Column("Value") }, Rows = new List<Row>() { new Row(new List<object>() { 14 }) } }; var converter = new MultipleResultSetConverter(new List<ResultSet>() { resultSet }); Assert.AreEqual(14, converter.ToScalar<int>()); }
public void ToMultipleResultSetModel_ToSingleOrDefaultRow_Works() { var resultSet = new ResultSet() { Columns = new List<Column>() { new Column("Value") }, Rows = new List<Row>() { new Row(new List<object>() { 23 }) } }; var converter = new MultipleResultSetConverter(new List<ResultSet>() { resultSet }); var model = converter.ToMultipleResultSetModel<MultipleResultSet_SingleOrDefaultRow_TestModel>(); Assert.AreEqual(23, model.SingleOrDefaultRow.Value); }
public void ToRows_SingleRow_Works() { var resultSet = new ResultSet() { Columns = new List<Column>() { new Column("Value") }, Rows = new List<Row>() { new Row(new List<object>() { 42 }) } }; var converter = new MultipleResultSetConverter(new List<ResultSet>() { resultSet }); var model = converter.ToRows<ScalarTestModel>(); Assert.AreEqual(1, model.Count); Assert.AreEqual(42, model[0].Value); }
public void ToMultipleResultSetModel_ToRows_Works() { var resultSet = new ResultSet() { Columns = new List<Column>() { new Column("Value") }, Rows = new List<Row>() { new Row(new List<object>() { 24 }) } }; var converter = new MultipleResultSetConverter(new List<ResultSet>() { resultSet }); var model = converter.ToMultipleResultSetModel<MultipleResultSet_Rows_TestModel>(); Assert.AreEqual(1, model.Rows.Count); Assert.AreEqual(24, model.Rows[0].Value); }
public void ToScalars_IsValid_Works() { var resultSet = new ResultSet() { Columns = new List<Column>() { new Column("Value") }, Rows = new List<Row>() { new Row(new List<object>() { 13 }), new Row(new List<object>() { 14 }), new Row(new List<object>() { 15 }) } }; var converter = new MultipleResultSetConverter(new List<ResultSet>() { resultSet }); var results = converter.ToScalars<int>(); Assert.AreEqual(3, results.Count); Assert.AreEqual(13, results[0]); Assert.AreEqual(14, results[1]); Assert.AreEqual(15, results[2]); }
public void ToMultipleResultSetModel_ToScalars_Works() { var resultSet = new ResultSet() { Columns = new List<Column>() { new Column("Value") }, Rows = new List<Row>() { new Row(new List<object>() { 21 }), new Row(new List<object>() { 22 }), new Row(new List<object>() { 23 }) } }; var converter = new MultipleResultSetConverter(new List<ResultSet>() { resultSet }); var model = converter.ToMultipleResultSetModel<MultipleResultSet_Scalars_TestModel>(); Assert.AreEqual(3, model.Values.Count); Assert.AreEqual(21, model.Values[0]); Assert.AreEqual(22, model.Values[1]); Assert.AreEqual(23, model.Values[2]); }
private List<ResultSet> ConvertReaderToMultipleResultSet(SqlDataReader reader) { var resultSets = new List<ResultSet>(); do { var resultSet = new ResultSet(); resultSet.Columns = GetColumns(reader); resultSet.Rows = GetRows(reader); resultSets.Add(resultSet); } while (reader.NextResult()); return resultSets; }