public void TestSelectManyManyMoreWords(int argsize) { //arrange LocalWordDB sut = new LocalWordDB(); sut.CreateDatabase(); List <DbWord> wordlist = new List <DbWord>(); for (int i = 0; i < argsize; i++) { wordlist.Add(new DbWord { Word = Guid.NewGuid().ToString(), SynsetId = Guid.NewGuid().ToString(), CreationDate = DateTime.Today }); } wordlist.Add(defaultDbWord); wordlist.Add(defaultDbWord2); sut.TryAddWord(defaultDbWord.Word, defaultDbWord.SynsetId).Should().BeTrue(); sut.TryAddWord(defaultDbWord2.Word, defaultDbWord2.SynsetId).Should().BeTrue(); //act sut.TryGetWords(wordlist, out IEnumerable <DbWord> data2).Should().BeTrue(); //assert var wordOut = data2.ToHashSet(); wordOut.Contains(defaultDbWord).Should().BeTrue(); wordOut.Contains(defaultDbWord2).Should().BeTrue(); //restore sut.DeleteDatabase(); }
public void TestUpdateWordsRelationStatus() { //arrange LocalWordDB sut = new LocalWordDB(); sut.CreateDatabase(); List <DbWord> wordlist = new List <DbWord> { new DbWord { Word = "test", SynsetId = "b:fzf4687", CreationDate = DateTime.Today, WordId = 1 }, new DbWord { Word = "test2", SynsetId = "b:vdqvqdv45", CreationDate = DateTime.Today, WordId = 2 } }; sut.TryAddWord(defaultDbWord.Word, defaultDbWord.SynsetId).Should().BeTrue(); sut.TryAddWord(defaultDbWord2.Word, defaultDbWord2.SynsetId).Should().BeTrue(); //act sut.UpdateWordRelationStatus(wordlist, true).Should().Be(2); //assert sut.TryGetWords(wordlist, out IEnumerable <DbWord> outDbWords).Should().BeTrue(); outDbWords.Count().Should().Be(wordlist.Count); outDbWords.Any(x => x.RelationsRequested == true).Should().BeTrue(); //restore sut.DeleteDatabase(); }
public void TestSelectManyWords() { //arrange LocalWordDB sut = new LocalWordDB(); sut.CreateDatabase(); List <DbWord> wordlist = new List <DbWord> { defaultDbWord, defaultDbWord2 }; sut.TryAddWord(defaultDbWord.Word, defaultDbWord.SynsetId).Should().BeTrue(); sut.TryAddWord(defaultDbWord2.Word, defaultDbWord2.SynsetId).Should().BeTrue(); //act-assert sut.TryGetWords(wordlist, out IEnumerable <DbWord> data2); DbWord[] wordSelected = data2.ToArray(); for (int i = 0; i < wordlist.Count; i++) { wordSelected[i].Should().Be(wordlist[i]); } //restore sut.DeleteDatabase(); }
public void TestAddRelationFromWordInfo() { //arrange LocalWordDB sut = new LocalWordDB(); sut.CreateDatabase(); sut.TryAddWord(defaultDbWord.Word, defaultDbWord.SynsetId).Should().BeTrue(); sut.TryAddWord(defaultDbWord2.Word, defaultDbWord2.SynsetId).Should().BeTrue(); //act-assert sut.TryAddRelation(defaultDbWord2.Word, defaultDbWord2.SynsetId, "Hyperonym").Should().BeTrue(); //restore sut.DeleteDatabase(); }
public void TestAddRelationToEmpty() { //arrange LocalWordDB sut = new LocalWordDB(); sut.CreateDatabase(); sut.TryAddWord(defaultDbWord.Word, defaultDbWord.SynsetId).Should().BeTrue(); sut.TryAddWord(defaultDbWord2.Word, defaultDbWord2.SynsetId).Should().BeTrue(); //act-assert sut.TryAddRelation(defaultDbWord2.Word, "b:578764644", "Hyperonym").Should().BeTrue(); sut.SynsetIdToSearch.Count.Should().Be(1); //restore sut.DeleteDatabase(); }
public void TestSelectWordsWithoutSynset() { //arrange LocalWordDB sut = new LocalWordDB(); sut.CreateDatabase(); List <DbWord> wordlist = new List <DbWord> { defaultDbWord, defaultDbWord2, new DbWord { Word = "test3", SynsetId = null, CreationDate = DateTime.Today } }; foreach (DbWord word in wordlist) { sut.TryAddWord(word.Word, word.SynsetId).Should().BeTrue(); } //act-assert sut.TryGetWordsWithoutSynset(1000, out IEnumerable <DbWord> outdbWords).Should().Be(1); outdbWords.First().Should().Be(wordlist.Last()); //restore sut.DeleteDatabase(); }
public void TestAddWordFromWord() { //arrange LocalWordDB sut = new LocalWordDB(); sut.CreateDatabase(); //act-assert sut.TryAddWord(defaultDbWord.Word, defaultDbWord.SynsetId).Should().BeTrue(); //restore sut.DeleteDatabase(); }
public void TestUpdateManyWords() { //arrange LocalWordDB sut = new LocalWordDB(); sut.CreateDatabase(); List <DbWord> wordlist = new List <DbWord> { defaultDbWord, defaultDbWord2 }; sut.TryAddWord(defaultDbWord.Word, defaultDbWord.SynsetId).Should().BeTrue(); sut.TryAddWord(defaultDbWord2.Word, defaultDbWord2.SynsetId).Should().BeTrue(); var updatedSynset = "b:04704254"; List <DbWord> wordlist2 = new List <DbWord> { new DbWord { Word = "test", SynsetId = updatedSynset, CreationDate = DateTime.Today } }; //act sut.TryUpdateDbWords(wordlist2).Should().Be(1); //assert sut.TryGetWords(wordlist, out IEnumerable <DbWord> outDbWords).Should().BeTrue(); outDbWords.Count().Should().Be(wordlist.Count); outDbWords.ToList().Where(x => x.Word == "test").First().SynsetId.Should().Be(updatedSynset); //restore sut.DeleteDatabase(); }
public void TestRelationsOfWord() { //arrange LocalWordDB sut = new LocalWordDB(); sut.CreateDatabase(); sut.TryAddWord(defaultDbWord.Word, defaultDbWord.SynsetId).Should().BeTrue(); sut.TryAddWord(defaultDbWord2.Word, defaultDbWord2.SynsetId).Should().BeTrue(); sut.TryAddRelation(defaultRelation).Should().BeTrue(); //act-assert var wordreturned = sut.TryGetRelationsSum(defaultDbWord); wordreturned.Word.Should().Be(defaultDbWord.Word); wordreturned.HyperonymCount.Should().Be(1); wordreturned.HyponymCount.Should().Be(0); wordreturned.OtherCount.Should().Be(0); //no hyponym !!! //restore sut.DeleteDatabase(); }
public void TestSelectWordFromWord() { //arrange LocalWordDB sut = new LocalWordDB(); sut.CreateDatabase(); //act-assert sut.TryGetWord(defaultDbWord.Word, out DbWord data).Should().BeFalse(); sut.TryAddWord(defaultDbWord.Word, defaultDbWord.SynsetId).Should().BeTrue(); sut.TryGetWord(defaultDbWord.Word, out DbWord data2).Should().BeTrue(); data2.Should().Be(defaultDbWord); //restore sut.DeleteDatabase(); }
public void TestAddWordFromWordMultiple(int count) { //arrange LocalWordDB sut = new LocalWordDB(); sut.CreateDatabase(); List <DbWord> wordlist = new List <DbWord>(); DbWord word; for (int i = 0; i < count; i++) { word = new DbWord { Word = Guid.NewGuid().ToString(), SynsetId = Guid.NewGuid().ToString(), CreationDate = DateTime.Today }; wordlist.Add(word); } //act-assert for (int i = 0; i < count; i++) { sut.TryAddWord(wordlist[i].Word, wordlist[i].SynsetId).Should().BeTrue(); } int countCheck = 0; foreach (DbWord word2 in wordlist) { sut.TryGetWord(word2.Word, out DbWord wordOut).Should().BeTrue(); countCheck++; } countCheck.Should().Be(wordlist.Count); //restore sut.DeleteDatabase(); }