Пример #1
0
        public void ToNewlineStringTest()
        {
            TestInfrastructure.DebugLineStart(TestContext);
            if (TestInfrastructure.IsActive(TestContext))
            {
                using (IDictionary writeLM = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser))
                {
                    ICard  card  = writeLM.Cards.AddNew();
                    IWords words = card.Question;

                    for (int i = 0; i < TestInfrastructure.Random.Next(10, 50); i++)
                    {
                        IWord word = words.CreateWord("Word " + i.ToString(), WordType.Word, true);
                        words.AddWord(word);
                    }

                    string newLineStringClone = string.Empty;
                    foreach (IWord var in words.Words)
                    {
                        newLineStringClone += var.Word + "\r\n";
                    }
                    newLineStringClone = newLineStringClone.Substring(0, newLineStringClone.Length - 2);

                    Assert.AreEqual <string>(newLineStringClone, words.ToNewlineString(), "IWords.ToNewlineStringTest does not match with expected output.");
                }
            }
            TestInfrastructure.DebugLineEnd(TestContext);
        }
Пример #2
0
        public static void CopyWords(IWords source, IWords target)
        {
            if (!typeof(IWords).IsAssignableFrom(target.GetType()))
            {
                throw new ArgumentException("Target must implement IWords!");
            }

            foreach (IWord word in source.Words)
            {
                IWord newWord = target.CreateWord(word.Word, word.Type, word.Default);
                target.AddWord(newWord);
            }
        }
Пример #3
0
        public void ClearWordsTest()
        {
            TestInfrastructure.DebugLineStart(TestContext);
            if (TestInfrastructure.IsActive(TestContext))
            {
                using (IDictionary writeLM = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser))
                {
                    ICard  card  = writeLM.Cards.AddNew();
                    IWords words = card.Question;

                    for (int i = 0; i < TestInfrastructure.Random.Next(10, 50); i++)
                    {
                        IWord word = words.CreateWord("Word " + i.ToString(), WordType.Word, true);
                        words.AddWord(word);
                    }

                    words.ClearWords();
                    Assert.IsTrue(words.Words.Count == 0, "IWords.ClearWords does not delete all words.");
                }
            }
            TestInfrastructure.DebugLineEnd(TestContext);
        }
Пример #4
0
        public static List <int> FillDummyDic(IDictionary target)
        {
            Debug.WriteLine(TestInfrastructure.beginLine + " Now filling Demodictionary " + TestInfrastructure.beginLine);
            List <int> chapters = new List <int>();

            for (int k = 0; k < 10; k++)
            {
                IChapter chapter = target.Chapters.AddNew();
                chapter.Title = "Chapter " + Convert.ToString(k + 1);
                chapters.Add(chapter.Id);

                target.DefaultSettings.SelectedLearnChapters.Add(chapter.Id);
                target.UserSettings.SelectedLearnChapters.Add(chapter.Id);
            }
            for (int k = 0; k < TestInfrastructure.Loopcount; k++)
            {
                ICard card = target.Cards.AddNew();
                card.Chapter = chapters[TestInfrastructure.Random.Next(0, chapters.Count)];
                int box = TestInfrastructure.Random.Next(0, 10);
                card.Box = (box == 11) ? -1 : box;
                List <IWord> questionWords       = new List <IWord>();
                List <IWord> questionDistractors = new List <IWord>();
                List <IWord> questionExamples    = new List <IWord>();
                List <IWord> answerWords         = new List <IWord>();
                List <IWord> answerDistractors   = new List <IWord>();
                List <IWord> answerExamples      = new List <IWord>();
                IWords       words = card.Question;
                for (int i = 0; i < TestInfrastructure.Random.Next(1, 5); i++)
                {
                    IWord word = words.CreateWord("Question_" + Convert.ToString(k + 1) + "_" + Convert.ToString(i + 1), WordType.Word, (i == 0));
                    questionWords.Add(word);
                }
                for (int i = 0; i < TestInfrastructure.Random.Next(1, 5); i++)
                {
                    IWord word = words.CreateWord("QuestionDistractor_" + Convert.ToString(k + 1) + "_" + Convert.ToString(i + 1), WordType.Distractor, false);
                    questionDistractors.Add(word);
                }
                for (int i = 0; i < TestInfrastructure.Random.Next(1, 5); i++)
                {
                    IWord word = words.CreateWord("QuestionExample_" + Convert.ToString(k + 1) + "_" + Convert.ToString(i + 1), WordType.Sentence, false);
                    questionExamples.Add(word);
                }
                words = card.Answer;
                for (int i = 0; i < TestInfrastructure.Random.Next(1, 5); i++)
                {
                    IWord word = words.CreateWord("Answer_" + Convert.ToString(k + 1) + "_" + Convert.ToString(i + 1), WordType.Word, (i == 0));
                    answerWords.Add(word);
                }
                for (int i = 0; i < TestInfrastructure.Random.Next(1, 5); i++)
                {
                    IWord word = words.CreateWord("AnswerDistractor_" + Convert.ToString(k + 1) + "_" + Convert.ToString(i + 1), WordType.Distractor, false);
                    answerDistractors.Add(word);
                }
                for (int i = 0; i < TestInfrastructure.Random.Next(1, 5); i++)
                {
                    IWord word = words.CreateWord("AnswerExample_" + Convert.ToString(k + 1) + "_" + Convert.ToString(i + 1), WordType.Sentence, false);
                    answerExamples.Add(word);
                }
                card.Question.AddWords(questionWords);
                card.QuestionDistractors.AddWords(questionDistractors);
                card.QuestionExample.AddWords(questionExamples);
                card.Answer.AddWords(answerWords);
                card.AnswerDistractors.AddWords(answerDistractors);
                card.AnswerExample.AddWords(answerExamples);
            }

            Debug.WriteLine(TestInfrastructure.endLine + " Demodictionary filled " + TestInfrastructure.endLine);
            return(chapters);
        }
Пример #5
0
        public static void CopyWords(IWords source, IWords target)
        {
            if (!typeof(IWords).IsAssignableFrom(target.GetType()))
                throw new ArgumentException("Target must implement IWords!");

            foreach (IWord word in source.Words)
            {
                IWord newWord = target.CreateWord(word.Word, word.Type, word.Default);
                target.AddWord(newWord);
            }
        }