本文整理汇总了C#中System.Data.Common.DbConnection.InitializeDB方法的典型用法代码示例。如果您正苦于以下问题:C# DbConnection.InitializeDB方法的具体用法?C# DbConnection.InitializeDB怎么用?C# DbConnection.InitializeDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Common.DbConnection
的用法示例。
在下文中一共展示了DbConnection.InitializeDB方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertAndGetFromFreshDB
public void InsertAndGetFromFreshDB()
{
//Given
connection = DBHelper.GetDbConnection(dbLocation);
connection.InitializeDB();
IMatchProvider provider = new MatchProvider(connection);
//When
provider.SaveMatchLevel1("near", "actual");
var matches = provider.GetMatches("near").ToList();
//Then
Assert.AreEqual(1, matches.Count());
Assert.IsTrue(matches.All(x => x.AltLevel1 == "near"));
}
示例2: InsertAndGetLevel2FromFreshDB
public void InsertAndGetLevel2FromFreshDB()
{
//Given
connection = DBHelper.GetDbConnection(dbLocation);
connection.InitializeDB();
IMatchProvider provider = new MatchProvider(connection);
//When
provider.SaveMatchLevel2("near", "level1", "level2");
var matches = provider.GetMatches("near", "level1");
//Then
Assert.AreEqual(1, matches.Count());
var match = matches.Single();
Assert.AreEqual("level2", match.Level2);
}
示例3: GetMatches_InputWithDifferentCase_RecordRetrieved
public void GetMatches_InputWithDifferentCase_RecordRetrieved()
{
// Arrange
connection = DBHelper.GetDbConnection(dbLocation);
connection.InitializeDB();
IMatchProvider provider = new MatchProvider(connection);
provider.SaveMatchLevel1("Near", "actual");
// Act
List<Level1Match> matchesLowerCase =
provider.GetMatches("near").ToList();
// Assert
Assert.AreEqual(1, matchesLowerCase.Count());
Assert.AreEqual("Near", matchesLowerCase.Single().AltLevel1);
Assert.AreEqual("actual", matchesLowerCase.Single().Level1);
}
示例4: SaveMatchLevel1_InsertDuplicateMatch_RecordOverwritten
public void SaveMatchLevel1_InsertDuplicateMatch_RecordOverwritten()
{
// Arrange
connection = DBHelper.GetDbConnection(dbLocation);
connection.InitializeDB();
IMatchProvider provider = new MatchProvider(connection);
// Act
provider.SaveMatchLevel1("input", "match_x");
provider.SaveMatchLevel1("input", "match_y");
IEnumerable<Level1Match> matches = provider.GetMatches("input").ToList();
// Asset
Assert.AreEqual(1, matches.Count());
var match = matches.Single();
Assert.AreEqual("input", match.AltLevel1);
Assert.AreEqual("match_y", match.Level1);
}
示例5: SaveMatchLevel1_InsertWithDifferentCase_RecordOverwritten
public void SaveMatchLevel1_InsertWithDifferentCase_RecordOverwritten()
{
// Arrange
connection = DBHelper.GetDbConnection(dbLocation);
connection.InitializeDB();
IMatchProvider provider = new MatchProvider(connection);
// Act
provider.SaveMatchLevel1("near", "actual");
provider.SaveMatchLevel1("Near", "actual");
List<Level1Match> matchesUpperCase =
provider.GetMatches("NEAR").ToList();
List<Level1Match> matchesLowerCase =
provider.GetMatches("near").ToList();
// Assert
Assert.AreEqual(1, matchesUpperCase.Count());
Assert.AreEqual(1, matchesLowerCase.Count());
Assert.AreEqual(
matchesUpperCase.First().MatchId,
matchesLowerCase.First().MatchId);
}
示例6: InsertTooLongMatch
public void InsertTooLongMatch()
{
//Given
connection = DBHelper.GetDbConnection(dbLocation);
connection.InitializeDB();
IMatchProvider provider = new MatchProvider(connection);
string tooLong = new String('a', maxLength + 1);
//When
provider.SaveMatchLevel1(tooLong, tooLong);
var matches = provider.GetMatches(tooLong);
//Then exception
}
示例7: InsertToFreshDBAndGetFromDeletedDB
public void InsertToFreshDBAndGetFromDeletedDB()
{
//Given
connection = DBHelper.GetDbConnection(dbLocation);
connection.InitializeDB();
IMatchProvider provider = new MatchProvider(connection);
//When
provider.SaveMatchLevel1("near", "actual");
provider.SaveMatchLevel1("near", "actual3");
connection.Close();
File.Delete(dbLocation);
connection = DBHelper.GetDbConnection(dbLocation);
connection.InitializeDB();
provider = new MatchProvider(connection);
var matches = provider.GetMatches("near");
connection.Close();
//Then
Assert.AreEqual(0, matches.Count());
}
示例8: InsertSpecialCharactersMatch
public void InsertSpecialCharactersMatch()
{
//Given
connection = DBHelper.GetDbConnection(dbLocation);
connection.InitializeDB();
IMatchProvider provider = new MatchProvider(connection);
string specialCharacters =
"%ùéèôçà六书/六書形声字/形聲字абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
int length = specialCharacters.Length;
//When
provider.SaveMatchLevel1(specialCharacters, specialCharacters);
var matches = provider.GetMatches(specialCharacters);
//Then
Assert.AreEqual(1, matches.Count());
var match = matches.Single();
Assert.AreEqual(specialCharacters.Length, match.AltLevel1.Length);
Assert.AreEqual(specialCharacters, match.AltLevel1);
Assert.AreEqual(specialCharacters, match.Level1);
}
示例9: InsertMaxLengthMatch
public void InsertMaxLengthMatch()
{
//Given
connection = DBHelper.GetDbConnection(dbLocation);
connection.InitializeDB();
IMatchProvider provider = new MatchProvider(connection);
string veryLong = new String('a', maxLength);
//When
provider.SaveMatchLevel1(veryLong, veryLong);
var matches = provider.GetMatches(veryLong);
//Then
Assert.AreEqual(1, matches.Count());
var match = matches.Single();
Assert.AreEqual(veryLong, match.AltLevel1);
Assert.AreEqual(veryLong, match.Level1);
}
示例10: GeoCoder_PerfsTestsUsingDictionaries
public void GeoCoder_PerfsTestsUsingDictionaries()
{
connection = DBHelper.GetDbConnection(dbLocation);
connection.InitializeDB();
GeoCoder geoCoder = new GeoCoder(connection);
geoCoder.LoadGazetteerFile(@"PHL_adm3.csv");
//You need to copy this file manually
Stopwatch watch = new Stopwatch();
watch.Start();
geoCoder.SetGazetteerColumns(
new GazetteerColumnHeaders
{
Level1Code = "ID_1",
Level2Code = "ID_2",
Level3Code = "ID_3",
Level1Name = "NAME_1",
Level2Name = "NAME_2",
Level3Name = "NAME_3"
},
false);
Debug.WriteLine("Time to create dictionaries: " + watch.Elapsed.TotalSeconds);
foreach (int linesCount in new[] {500, 1000, 2000})
{
geoCoder.LoadInputFileCsv(GenerateInputFile(linesCount));
geoCoder.SetInputColumns(geoCoder.DefaultInputColumnHeaders());
watch.Restart();
geoCoder.AddAllLocationCodes();
var elapsed = watch.Elapsed.TotalSeconds;
//LocationCodes.useDictionaries = !LocationCodes.useDictionaries;
geoCoder.LoadInputFileCsv(GenerateInputFile(linesCount));
geoCoder.SetInputColumns(geoCoder.DefaultInputColumnHeaders());
watch.Restart();
geoCoder.AddAllLocationCodes();
Debug.WriteLine(
linesCount + " input lines: " + elapsed + " vs " +
watch.Elapsed.TotalSeconds);
// LocationCodes.useDictionaries = !LocationCodes.useDictionaries;
foreach (var row in geoCoder.InputData.AsEnumerable())
{
var elems = row.ItemArray;
Assert.IsFalse(elems[5] is DBNull);
Assert.IsFalse(elems[6] is DBNull);
Assert.IsFalse(elems[7] is DBNull);
}
}
}