public static void FillDummyDic(Dictionary dictionary)
        {
            List <int> chapters = new List <int>();

            for (int k = 0; k < 10; k++)
            {
                int chapterId = dictionary.Chapters.AddChapter("Chapter " + Convert.ToString(k + 1), "Chapter Description" + Convert.ToString(k + 1));
                chapters.Add(chapterId);
                dictionary.QueryChapters.Add(chapterId);
            }
            for (int i = 0; i < TestInfrastructure.LoopCount; i++)
            {
                bool hasQImage = TestInfrastructure.RandomBool, hasAImage = TestInfrastructure.RandomBool;
                bool hasQAudio = TestInfrastructure.RandomBool, hasAAudio = TestInfrastructure.RandomBool;
                bool hasQEAudio = TestInfrastructure.RandomBool, hasAEAudio = TestInfrastructure.RandomBool;
                bool hasQVideo = TestInfrastructure.RandomBool, hasAVideo = TestInfrastructure.RandomBool;
                bool hasQExample = TestInfrastructure.RandomBool, hasAExample = TestInfrastructure.RandomBool;
                int  cardId = dictionary.Cards.AddCard("question " + i, "answer " + i, (hasQExample) ? "question example " + i : String.Empty, (hasAExample) ? "answer example " + i : String.Empty, String.Empty, String.Empty, chapters[TestInfrastructure.Random.Next(0, chapters.Count)]);
                if (hasQImage)
                {
                    dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestImage(), EMedia.Image, Side.Question, true, true, false);
                }
                if (hasAImage)
                {
                    dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestImage(), EMedia.Image, Side.Answer, true, true, false);
                }
                if (hasQAudio)
                {
                    dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestAudio(), EMedia.Audio, Side.Question, true, true, false);
                }
                if (hasAAudio)
                {
                    dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestAudio(), EMedia.Audio, Side.Answer, true, true, false);
                }
                if (hasQEAudio)
                {
                    dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestAudio(), EMedia.Audio, Side.Question, true, false, true);
                }
                if (hasAEAudio)
                {
                    dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestAudio(), EMedia.Audio, Side.Answer, true, false, true);
                }
                if (hasQVideo)
                {
                    dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestVideo(), EMedia.Video, Side.Question, true, true, false);
                }
                if (hasAVideo)
                {
                    dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestVideo(), EMedia.Video, Side.Answer, true, true, false);
                }
            }
        }
Пример #2
0
 public void CardContainsMediaTest()
 {
     if (TestInfrastructure.IsActive(TestContext))
     {
         using (Dictionary dictionary = TestInfrastructure.GetConnection(TestContext))
         {
             int chapterId = dictionary.Chapters.AddChapter("test chapter", "test chapter Description");
             for (int i = 0; i < TestInfrastructure.LoopCount; i++)
             {
                 bool hasQImage = TestInfrastructure.RandomBool, hasAImage = TestInfrastructure.RandomBool;
                 bool hasQAudio = TestInfrastructure.RandomBool, hasAAudio = TestInfrastructure.RandomBool;
                 bool hasQEAudio = TestInfrastructure.RandomBool, hasAEAudio = TestInfrastructure.RandomBool;
                 bool hasQVideo = TestInfrastructure.RandomBool, hasAVideo = TestInfrastructure.RandomBool;
                 int  cardId = dictionary.Cards.AddCard("question", "answer", "question example", "answer example", String.Empty, String.Empty, chapterId);
                 if (hasQImage)
                 {
                     dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestImage(), EMedia.Image, Side.Question, true, true, false);
                 }
                 if (hasAImage)
                 {
                     dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestImage(), EMedia.Image, Side.Answer, true, true, false);
                 }
                 if (hasQAudio)
                 {
                     dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestAudio(), EMedia.Audio, Side.Question, true, true, false);
                 }
                 if (hasAAudio)
                 {
                     dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestAudio(), EMedia.Audio, Side.Answer, true, true, false);
                 }
                 if (hasQEAudio)
                 {
                     dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestAudio(), EMedia.Audio, Side.Question, true, false, true);
                 }
                 if (hasAEAudio)
                 {
                     dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestAudio(), EMedia.Audio, Side.Answer, true, false, true);
                 }
                 if (hasQVideo)
                 {
                     dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestVideo(), EMedia.Video, Side.Question, true, true, false);
                 }
                 if (hasAVideo)
                 {
                     dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestVideo(), EMedia.Video, Side.Answer, true, true, false);
                 }
                 Card card = dictionary.Cards.GetCardByID(cardId);
                 if (hasQImage)
                 {
                     Assert.IsTrue(card.ContainsImage(Side.Question.ToString()), "Card does not contain question image!");
                 }
                 else
                 {
                     Assert.IsFalse(card.ContainsImage(Side.Question.ToString()), "Card contains question image!");
                 }
                 if (hasAImage)
                 {
                     Assert.IsTrue(card.ContainsImage(Side.Answer.ToString()), "Card does not contain answer image!");
                 }
                 else
                 {
                     Assert.IsFalse(card.ContainsImage(Side.Answer.ToString()), "Card contains answer image!");
                 }
                 if (hasQAudio)
                 {
                     Assert.IsTrue(card.ContainsAudio(Side.Question.ToString()), "Card does not contain question audio!");
                 }
                 else
                 {
                     Assert.IsFalse(card.ContainsAudio(Side.Question.ToString()), "Card contains question audio!");
                 }
                 if (hasAAudio)
                 {
                     Assert.IsTrue(card.ContainsAudio(Side.Answer.ToString()), "Card does not contain answer audio!");
                 }
                 else
                 {
                     Assert.IsFalse(card.ContainsAudio(Side.Answer.ToString()), "Card contains answer audio!");
                 }
                 if (hasQEAudio)
                 {
                     Assert.IsTrue(card.ContainsExampleAudio(Side.Question.ToString()), "Card does not contain question example audio!");
                 }
                 else
                 {
                     Assert.IsFalse(card.ContainsExampleAudio(Side.Question.ToString()), "Card contains question example audio!");
                 }
                 if (hasAEAudio)
                 {
                     Assert.IsTrue(card.ContainsExampleAudio(Side.Answer.ToString()), "Card does not contain answer example audio!");
                 }
                 else
                 {
                     Assert.IsFalse(card.ContainsExampleAudio(Side.Answer.ToString()), "Card contains answer example audio!");
                 }
                 if (hasQVideo)
                 {
                     Assert.IsTrue(card.ContainsVideo(Side.Question.ToString()), "Card does not contain question video!");
                 }
                 else
                 {
                     Assert.IsFalse(card.ContainsVideo(Side.Question.ToString()), "Card contains question video!");
                 }
                 if (hasAVideo)
                 {
                     Assert.IsTrue(card.ContainsVideo(Side.Answer.ToString()), "Card does not contain answer video!");
                 }
                 else
                 {
                     Assert.IsFalse(card.ContainsVideo(Side.Answer.ToString()), "Card contains answer video!");
                 }
             }
         }
     }
 }