Пример #1
0
        public void QuestionAnswerContentTest()
        {
            this.SchoolNet().LoadWebPage();
            QuestionAnswerContent questionAnswerContent = new QuestionAnswerContent("T", 0, "ctl01", ContentType.AnswerChoice, ItemType.TrueFalse);

            Assert.AreEqual("T", questionAnswerContent.Label);
            Assert.AreEqual(0, questionAnswerContent.Index);
            Assert.AreEqual("ctl01", questionAnswerContent.UniqueId);
        }
Пример #2
0
        public void ByChoiceCanBeUsedSelectTest()
        {
            this.SchoolNet().LoadWebPage();
            int    index               = 0;
            string uniqueId            = "ctl01";
            QuestionAnswerContent form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AvailableChoice, ItemType.DragAndDrop);

            Assert.AreEqual("By.CssSelector: .listChoices li[data-ng-repeat='choice in TestItem.Choices']:nth-of-type(" + index + ") select",
                            form.ByChoiceCanBeUsedSelect().ToString(), "ByChoiceCanBeUsedSelect locator matches");
        }
Пример #3
0
        public void ByContentLabelTest()
        {
            this.SchoolNet().LoadWebPage();
            int    index               = 0;
            string uniqueId            = "ctl01";
            QuestionAnswerContent form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AnswerChoice, ItemType.MultipleChoice);

            Assert.AreEqual("By.Id: ctl00_MainContent_EditTestItemControl_RepeaterAnswers_" + uniqueId + "_txtAnswerLabel",
                            form.ByContentLabel().ToString(), "ByContentLabel locator matches");

            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AnswerChoice, ItemType.TrueFalse);
            Assert.AreEqual("By.Id: ctl00_MainContent_EditTestItemControl_RepeaterAnswers_" + uniqueId + "_txtAnswerLabel",
                            form.ByContentLabel().ToString(), "ByContentLabel locator matches");

            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AnswerChoice, ItemType.InlineResponse);
            Assert.AreEqual("By.Id: ctl00_MainContent_EditTestItemControl_RepeaterClozeStemAnswers_" + uniqueId + "_txtAnswerLabel",
                            form.ByContentLabel().ToString(), "ByContentLabel locator matches");

            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AnswerChoice, ItemType.DragAndDrop);
            Assert.AreEqual("By.CssSelector: .tab-pane.ng-scope.active .listChoices li[data-ng-repeat='tabChoice in tab.AllChoices']:nth-of-type(" + index + ") .AnswerLabel",
                            form.ByContentLabel().ToString(), "ByContentLabel locator matches");

            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AnswerChoice, ItemType.HotSpotSingleSelection);
            Assert.AreEqual("By.CssSelector: #tblAnswers tbody[ng-repeat='answer in TestItem.Answers']:nth-of-type(" + index + ") .AnswerLabel",
                            form.ByContentLabel().ToString(), "ByContentLabel locator matches");


            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AvailableChoice, ItemType.Matching);
            Assert.AreEqual("By.Id: ctl00_MainContent_EditTestItemControl_choicesRepeator_" + uniqueId + "_txtChoiceLabel",
                            form.ByContentLabel().ToString(), "ByContentLabel locator matches");

            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AvailableChoice, ItemType.DragAndDrop);
            Assert.AreEqual("By.CssSelector: .listChoices li[data-ng-repeat='choice in TestItem.Choices']:nth-of-type(" + index + ") .AnswerLabel",
                            form.ByContentLabel().ToString(), "ByContentLabel locator matches");


            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.QuestionStem, ItemType.TrueFalse);
            Assert.AreEqual("By.Id: ctl00_MainContent_EditTestItemControl_stemRepeator_" + uniqueId + "_txtStemLabel",
                            form.ByContentLabel().ToString(), "ByContentLabel locator matches");


            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.TargetContainer, ItemType.TrueFalse);
            Assert.AreEqual("By.CssSelector: .listChoices li[data-ng-repeat='container in TestItem.Containers']:nth-of-type(" + index + ") .AnswerLabel",
                            form.ByContentLabel().ToString(), "ByContentLabel locator matches");
        }
Пример #4
0
        public void ByContentRemoveTest()
        {
            this.SchoolNet().LoadWebPage();
            int    index               = 0;
            string uniqueId            = "ctl01";
            QuestionAnswerContent form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AnswerChoice, ItemType.MultipleChoice);

            Assert.AreEqual("By.Id: ctl00_MainContent_EditTestItemControl_RepeaterAnswers_" + uniqueId + "_LinkButton1",
                            form.ByContentRemove().ToString(), "ByContentRemove locator matches");

            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AnswerChoice, ItemType.TrueFalse);
            Assert.AreEqual("By.Id: ctl00_MainContent_EditTestItemControl_RepeaterAnswers_" + uniqueId + "_LinkButton1",
                            form.ByContentRemove().ToString(), "ByContentRemove locator matches");

            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AnswerChoice, ItemType.InlineResponse);
            Assert.AreEqual("By.Id: ctl00_MainContent_EditTestItemControl_RepeaterClozeStemAnswers_" + uniqueId + "_DelClozeChoice",
                            form.ByContentRemove().ToString(), "ByContentRemove locator matches");

            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AnswerChoice, ItemType.DragAndDrop);
            Assert.AreEqual("By.CssSelector: ",
                            form.ByContentRemove().ToString(), "ByContentRemove locator matches");

            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AnswerChoice, ItemType.HotSpotSingleSelection);
            Assert.AreEqual("By.CssSelector: #tblAnswers tbody[ng-repeat='answer in TestItem.Answers']:nth-of-type(" + index + ") .pull-right > a",
                            form.ByContentRemove().ToString(), "ByContentRemove locator matches");


            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AvailableChoice, ItemType.Matching);
            Assert.AreEqual("By.Id: ctl00_MainContent_EditTestItemControl_choicesRepeator_" + uniqueId + "_lnkDeleteChoice",
                            form.ByContentRemove().ToString(), "ByContentRemove locator matches");

            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.AvailableChoice, ItemType.DragAndDrop);
            Assert.AreEqual("By.CssSelector: .listChoices li[data-ng-repeat='choice in TestItem.Choices']:nth-of-type(" + index + ") a",
                            form.ByContentRemove().ToString(), "ByContentRemove locator matches");


            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.QuestionStem, ItemType.TrueFalse);
            Assert.AreEqual("By.Id: ctl00_MainContent_EditTestItemControl_stemRepeator_" + uniqueId + "_lnkDeleteStem",
                            form.ByContentRemove().ToString(), "ByContentRemove locator matches");


            form = new QuestionAnswerContent("T", index, uniqueId, ContentType.TargetContainer, ItemType.TrueFalse);
            Assert.AreEqual("By.CssSelector: .listChoices li[data-ng-repeat='container in TestItem.Containers']:nth-of-type(" + index + ") a",
                            form.ByContentRemove().ToString(), "ByContentRemove locator matches");
        }
        private void SetUniqueControlIdentifiers()
        {
            //get a hash of the answer choice's: label and unique control identifier using WebDriver.FindElements(By.ClassName)
            QuestionStemUniqueControlIdentifiers = GetUniqueControlIdentifiers(ByMatchQuestionStemLabels);
            AnswerChoiceUniqueControlIdentifiers = GetUniqueControlIdentifiers(ByMatchAnswerChoiceLabels);
            //get the list of answer labels
            var keyList = new List <string>();

            foreach (var key in AnswerChoiceUniqueControlIdentifiers.Keys)
            {
                keyList.Add(key);
            }

            QuestionStemList = new List <QuestionAnswerContent>();
            //for each element in the hash
            foreach (var key in QuestionStemUniqueControlIdentifiers.Keys)
            {
                //is the key numeric?
                int  index;
                bool isNumeric = int.TryParse(key, out index);
                if (isNumeric == true)
                {
                    //get a numeric zero based index by subtracting 1 from the number of the question label
                    index = index - 1;
                    //get the unique control identifier
                    string uniqueId = QuestionStemUniqueControlIdentifiers[key];
                    Report.Write("Question stem unique control identifier by key: " + key + "; index: " + index + "; ID: " + uniqueId);
                    //create an question stem object
                    var questionStem = new QuestionAnswerContent(key, index, uniqueId, ContentType.QuestionStem, ItemType.Matching, ControlPrefix);
                    //add the question stem object to the collection (1, 2, 3)
                    QuestionStemList.Add(questionStem);
                }
            }

            AnswerChoiceList = new List <QuestionAnswerContent>();
            //for each element in the hash
            foreach (var key in AnswerChoiceUniqueControlIdentifiers.Keys)
            {
                //is the key numeric?
                int  index;
                bool isNumeric = int.TryParse(key, out index);
                if (isNumeric == false)
                {
                    //get a numeric zero based index based on the letter of the answer label
                    index = this.GetIndexByAlphabet(key, keyList);
                    //get the unique control identifier
                    string uniqueId = AnswerChoiceUniqueControlIdentifiers[key];
                    Report.Write("Answer choice unique control identifier by key: " + key + "; index: " + index + "; ID: " + uniqueId);
                    //create an answer choice object
                    var answerChoice = new QuestionAnswerContent(key, index, uniqueId, ContentType.AvailableChoice, ItemType.Matching, ControlPrefix);
                    //add the answer choice object to the collection (A, B, C, D)
                    AnswerChoiceList.Add(answerChoice);
                }
            }

            MatchingPairList = new List <MatchingPair>();
            //for each element in the hash
            foreach (var key in QuestionStemUniqueControlIdentifiers.Keys)
            {
                //is the key numeric?
                int  index;
                bool isNumeric = int.TryParse(key, out index);
                if (isNumeric == true)
                {
                    //get a numeric zero based index by subtracting 1 from the number of the question label
                    index = index - 1;
                    //get the unique control identifier
                    string uniqueId = QuestionStemUniqueControlIdentifiers[key];
                    Report.Write("Matching pair unique control identifier by key: " + key + "; index: " + index + "; ID: " + uniqueId);
                    //create an question stem object
                    var matchingPair = new MatchingPair(key, index, uniqueId, ControlPrefix);
                    //add the question stem object to the collection (1, 2, 3)
                    MatchingPairList.Add(matchingPair);
                }
            }
        }