public void TestExecuteScalarCount() { KoraliumConnectionStringBuilder builder = new KoraliumConnectionStringBuilder(); builder.DataSource = webFactory.GetUrl(); KoraliumConnection connection = new KoraliumConnection(); connection.ConnectionString = builder.ConnectionString; connection.Open(); var cmd = connection.CreateCommand(); cmd.CommandText = "select count(*) from project"; var value = cmd.ExecuteScalar(); Assert.AreEqual(2, value); }
public void TestDecimalValueGetDataTypeName() { KoraliumConnectionStringBuilder builder = new KoraliumConnectionStringBuilder(); builder.DataSource = webFactory.GetUrl(); KoraliumConnection connection = new KoraliumConnection(); connection.ConnectionString = builder.ConnectionString; connection.Open(); var cmd = connection.CreateCommand(); cmd.CommandText = "select decimalvalue from typetest"; var reader = cmd.ExecuteReader(); string actual = reader.GetDataTypeName(0); Assert.AreEqual("decimal", actual); }
public void TestGetDecimalValueGetValue() { KoraliumConnectionStringBuilder builder = new KoraliumConnectionStringBuilder(); builder.DataSource = webFactory.GetUrl(); KoraliumConnection connection = new KoraliumConnection(); connection.ConnectionString = builder.ConnectionString; connection.Open(); var cmd = connection.CreateCommand(); cmd.CommandText = "select decimalvalue from typetest"; var reader = cmd.ExecuteReader(); var decimalordinal = reader.GetOrdinal("decimalvalue"); List <object> actual = new List <object>(); while (reader.Read()) { var val = reader.GetValue(decimalordinal); actual.Add(val); } List <decimal> expected = new List <decimal> { 1, 3, 17, 1, 3 }; Assert.AreEqual(expected, actual); }
public void TestSelectString() { KoraliumConnectionStringBuilder builder = new KoraliumConnectionStringBuilder(); builder.DataSource = webFactory.GetUrl(); KoraliumConnection connection = new KoraliumConnection(); connection.ConnectionString = builder.ConnectionString; connection.Open(); var cmd = connection.CreateCommand(); cmd.CommandText = "select * from project"; var reader = cmd.ExecuteReader(); var companyOrdinal = reader.GetOrdinal("company"); while (reader.Read()) { var company = reader.GetFieldValue <Company>(companyOrdinal); } }