Example #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);
        }
Example #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);
            }
        }
Example #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);
        }
Example #4
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);
            }
        }