コード例 #1
0
 public void GetAllWords()
 {
     using (var ctx = new SpellCheckerContext())
     {
         var repository = new WordRepository(ctx);
         var all = repository.All;
         Assert.IsTrue(all.ToList().Count.Equals(100));
     }
 }
コード例 #2
0
 public void GetOneWordById()
 {
     using (var ctx = new SpellCheckerContext())
     {
         var repository = new WordRepository(ctx);
         var firstWord = repository.Find(1);
         Assert.AreEqual("cheese", firstWord.EnglishText);
         Assert.AreEqual("ost", firstWord.SwedishText);
     }
 }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: hnrkhlmr/SpellChecker
        public void GetWordsForTestTest()
        {
            using (var ctx = new SpellCheckerContext())
            {
                var repository = new WordRepository();
                var testWordDtos = repository.GetWordsForTest(1);

                Assert.AreEqual(10, testWordDtos.Count());
            }
        }
コード例 #4
0
ファイル: UnitTest1.cs プロジェクト: hnrkhlmr/SpellChecker
        public void TestMethod1()
        {
            using (var ctx = new SpellCheckerContext())
            {
                var repository = new WordRepository(ctx);
                var stats = repository.GetSpellingBeeTestStats(2);

                Assert.IsTrue(stats.Any());
            }
        }
コード例 #5
0
ファイル: DataTest.cs プロジェクト: hnrkhlmr/SpellChecker
 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));
     }
 }
コード例 #6
0
ファイル: UnitTest1.cs プロジェクト: hnrkhlmr/SpellChecker
        public void GetAverageScoreTest()
        {
            using (var ctx = new SpellCheckerContext())
            {
                var repository = new WordRepository();
                var testStat = repository.GetSpellingBeeTestStats(2).ToList();

                Assert.AreEqual(4, testStat.Count());
                Assert.AreEqual(6, testStat[1].NumberOfTests);
                Assert.AreEqual(33, decimal.Round(Convert.ToDecimal(testStat[1].AverageScore)));
            }
            /*
             * 
             * SpellingBeeTestId	Name	WordsPerTest	TestDone	AverageScore
                1	First IESH Spelling Bee 4th grade 2016	10	10	39
                2	Weekdays	7	6	33
                3	Months	12	0	NULL
                4	Veckans ord v6 2016	12	1	58
             * */
        }
コード例 #7
0
ファイル: DataTest.cs プロジェクト: hnrkhlmr/SpellChecker
 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));
     }
 }
コード例 #8
0
ファイル: DataTest.cs プロジェクト: hnrkhlmr/SpellChecker
 public void CreateSeedData()
 {
     using (var ctx = new SpellCheckerContext())
     {
         var sb = new StringBuilder("Words = new List<SpellChecker.Dal.DomainObjects.Word>");
         sb.AppendLine("{");
         var repository = new WordRepository(ctx);
         var words = repository.All.Where(w => w.SpellingBeeTestId.Equals(1)).ToList();
         foreach (var word in words)
         {
             sb.AppendLine(string.Format("new SpellChecker.Dal.DomainObjects.Word {{ EnglishText = \"{0}\", SwedishText = \"{1}\" }},", word.EnglishText, word.SwedishText));
         }
         sb.AppendLine("}");
         using (var sw = new StreamWriter(@"c:\xml\spellchecker\words.cs"))
         {
             sw.Write(sb.ToString());
         }
     }
     
     /*
      * 
         Words = new List<SpellChecker.Dal.DomainObjects.Word>
         {
             new SpellChecker.Dal.DomainObjects.Word { EnglishText = "monday", SwedishText = "måndag" },
             new SpellChecker.Dal.DomainObjects.Word { EnglishText = "tuesday", SwedishText = "tisdag" },
             new SpellChecker.Dal.DomainObjects.Word { EnglishText = "wednesday", SwedishText = "onsdag" },
             new SpellChecker.Dal.DomainObjects.Word { EnglishText = "thursday", SwedishText = "torsdag" },
             new SpellChecker.Dal.DomainObjects.Word { EnglishText = "friday", SwedishText = "fredag" },
             new SpellChecker.Dal.DomainObjects.Word { EnglishText = "saturday", SwedishText = "lördag" },
             new SpellChecker.Dal.DomainObjects.Word { EnglishText = "sunday", SwedishText = "söndag" }
         }
      */
 }