本文整理汇总了C#中Db.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# Db.Connect方法的具体用法?C# Db.Connect怎么用?C# Db.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Db
的用法示例。
在下文中一共展示了Db.Connect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestIfSingleCellValueIsSelected
public void TestIfSingleCellValueIsSelected()
{
var db = new Db();
db.Connect();
if (db.IsConnected())
{
db.Connect();
db.bind("id", "1");
string p = db.single("select age from persons where id = @id");
Assert.AreEqual(p, "19");
db.CloseConn();
}
}
示例2: TestIfInvalidConnectionString
public void TestIfInvalidConnectionString()
{
var db = new Db();
db.ConString = "Server=localhosts;Database=testdb;Uid=root;Pwd=;";//erroneous
db.Connect();
Assert.AreEqual(db.IsConnected(), false);
}
示例3: Connect_WhenCalled_OpensConnection
public void Connect_WhenCalled_OpensConnection()
{
var connection = Substitute.For<IDbConnection>();
var db = new Db(connection, DbConfig.Default);
db.Connect();
connection.Received(1).Open();
}
示例4: TestIfValidConnectionString
public void TestIfValidConnectionString()
{
var db = new Db();
db.Connect();
Assert.AreEqual(db.IsConnected(), true);
db.CloseConn();
Assert.AreEqual(db.IsConnected(), false);
}
示例5: TestIfRowValuesAreSelected
public void TestIfRowValuesAreSelected()
{
var db = new Db();
db.Connect();
if (db.IsConnected())
{
db.bind("id", "1");
string[] p = db.row("select * from persons where id = @id");
Assert.AreEqual(p[0], "1");
Assert.AreEqual(p[1], "John");
Assert.AreEqual(p[2], "Doe");
db.CloseConn();
}
}