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")); }
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); }
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); }
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); }
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 }
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()); }
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); }
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); }