本文整理汇总了C#中DatabaseHelper.CreateDatabase方法的典型用法代码示例。如果您正苦于以下问题:C# DatabaseHelper.CreateDatabase方法的具体用法?C# DatabaseHelper.CreateDatabase怎么用?C# DatabaseHelper.CreateDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseHelper
的用法示例。
在下文中一共展示了DatabaseHelper.CreateDatabase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_Dump_Table_Data_To_Separate_Scripts
public void Should_Dump_Table_Data_To_Separate_Scripts()
{
// Given that I have a database with more than one table and each contains some data
DatabaseHelper db = new DatabaseHelper();
db.CreateDatabase();
TableHelper table1 = new TableHelper();
table1.CreateTable("Person", t =>
{
t.column("ID", ColumnType.Integer, true, false, true);
t.column("Name", ColumnType.String);
t.column("Age", ColumnType.Integer);
})
.AddRow("Colin", 28)
.AddRow("Katherine", 25);
TableHelper table2 = new TableHelper();
table2.CreateTable("Animal", t =>
{
t.column("ID", ColumnType.Integer, true, false, true);
t.column("Name", ColumnType.String);
t.column("Kind", ColumnType.String);
})
.AddRow("Tiny", "Cat")
.AddRow("Mayzie", "Dog");
// When I dump the data
IDataManager dumper = new MsSqlDataManager();
List<InsertionScript> scripts = dumper.DumpTables(Test.Settings.ServerName, Test.Settings.DatabaseName);
// I should get a data insertion script for each table
var personScript = scripts.Where(s => s.TableName == "Person").FirstOrDefault();
var animalScript = scripts.Where(s => s.TableName == "Animal").FirstOrDefault();
Assert.IsNotNull(personScript);
Assert.IsNotNull(animalScript);
// And the scripts should have INSERT statements
StringAssert.Matches(personScript.Script, new Regex("INSERT.*Person.*'Colin'.*28"));
StringAssert.Matches(animalScript.Script, new Regex("INSERT.*Animal.*'Tiny'.*'Cat'"));
}