Пример #1
0
 public void LoadDatabaseFromXmlFile()
 {
     using (var ctx = new SpellCheckerContext())
     {
         var fileWordName = "words.xml";
         var words = new List<SpellChecker.Dal.DomainObjects.Word>();
         var wordsFromXml = XmlHelper.ReadXml<List<SpellChecker.Dal.DomainObjects.Word>>(fileWordName);
         Assert.IsTrue(wordsFromXml.Count.Equals(100));
         var repository = new WordRepository(ctx);
         foreach (var word in wordsFromXml)
         {
             word.WordId = 0;
             repository.InsertOrUpdate(word);
         }
         var all = repository.All;
         Assert.IsTrue(all.ToList().Count.Equals(100));
     }
 }
Пример #2
0
 public void UpdateSwedishTextInDbFromXmlFile()
 {
     using (var ctx = new SpellCheckerContext())
     {
         var fileWordName = "words.xml";
         var words = new List<SpellChecker.Dal.DomainObjects.Word>();
         var wordsFromXml = XmlHelper.ReadXml<List<SpellChecker.Dal.DomainObjects.Word>>(fileWordName);
         var repository = new WordRepository(ctx);
         foreach (var word in wordsFromXml)
         {
             var dbword = repository.Find(word.WordId);
             dbword.SwedishText = word.SwedishText;
             repository.InsertOrUpdate(dbword);
         }
         var all = repository.All;
         Assert.IsTrue(all.Where(w => w.SwedishText!=null).ToList().Count.Equals(100));
         Assert.IsTrue(all.ToList().Count.Equals(100));
     }
 }