Пример #1
0
        public void CanApplyPatternTest()
        {
            int excCount = 0;

            try
            {
                pattern.CanApplyPattern(null);
            }
            catch (ArgumentNullException)
            {
                excCount++;
            }

            Assert.IsFalse(pattern.CanApplyPattern(excCount));
            Assert.IsFalse(pattern.CanApplyPattern(organization));
            Assert.IsFalse(pattern.CanApplyPattern(chapter));

            ItemType chapter1        = ItemType.CreateNewItem("chapter1", "chapter1_id", null, PageType.Chapter);
            ItemType controlChapter1 = ItemType.CreateNewItem("controlChapter1", "controlChapter1_id", null, PageType.ControlChapter);
            ItemType theory          = ItemType.CreateNewItem("theory1", "theory_id", null, PageType.Theory);

            this.controlChapter.SubItems.Add(theory);
            Assert.IsTrue(pattern.CanApplyPattern(controlChapter));

            this.organization.SubItems.Add(theory);
            this.organization.SubItems.Add(controlChapter1);
            Assert.IsTrue(pattern.CanApplyPattern(this.organization));

            theory.SubItems.Add(chapter1);
            Assert.IsFalse(pattern.CanApplyPattern(theory));
        }
Пример #2
0
        private void AddChapter(PageType chapterType)
        {
            var           treeNode = tvItems.SelectedNode;
            var           manNode  = treeNode.Tag as IManifestNode;
            IManifestNode n;

            if (manNode is IItemContainer)
            {
                var newItem = ItemType.CreateNewItem(String.Format("New {0}", chapterType), Guid.NewGuid().ToString(), null, chapterType);
                n = newItem;
                (manNode as IItemContainer).SubItems.Add(newItem);
                tvItems.SelectedNode = treeNode.Nodes.Find(n.UID, true)[0];
            }
            else
            {
                var o = new OrganizationType {
                    Title = String.Format("New {0}", chapterType)
                };
                n = o;
                Course.Manifest.organizations.Organizations.Add(o);
            }

            treeNode = treeNode.Nodes.Find(n.UID, true)[0];
            treeNode.BeginEdit();
        }
Пример #3
0
        public void InsertGroupingChapter_ExceptionsTest()
        {
            int excCounter = 0;

            try
            {
                this.item.InsertGroupingItem(null);
            }
            catch (ArgumentNullException)
            {
                excCounter++;
            }

            try
            {
                ItemType item1 = ItemType.CreateNewItem("Item1", "Item1ID", null, PageType.Theory);
                this.item.InsertGroupingItem(item1);
            }
            catch (ArgumentException)
            {
                excCounter++;
            }

            Assert.AreEqual(2, excCounter);
        }
Пример #4
0
 public void SetUp()
 {
     this.pattern        = new SequencingPattern();
     this.organization   = new OrganizationType();
     this.chapter        = ItemType.CreateNewItem("Chapter", "chapter_base", null, PageType.Chapter);
     this.controlChapter = ItemType.CreateNewItem("Control Chapter", "control chapter", null, PageType.ControlChapter);
 }
Пример #5
0
        public void RemoveAndMerge_ExceptionTest()
        {
            this.item.Parent = new ObjectivesTypeObjective("Id123");

            ItemType item1 = ItemType.CreateNewItem("SubItem1", "SubItem1", null, PageType.Theory);
            ItemType item2 = ItemType.CreateNewItem("SubItem2", "SubItem2", null, PageType.Chapter);

            this.item.SubItems.Add(item1);
            this.item.SubItems.Add(item2);

            this.item.RemoveAndMerge();
        }
Пример #6
0
        public void AreAllChaptersTest()
        {
            Assert.IsTrue(SequencingPattern.AreAllChapters(this.organization));

            this.organization.SubItems.Add(chapter);
            this.organization.SubItems.Add(controlChapter);

            Assert.IsTrue(SequencingPattern.AreAllChapters(organization));

            ItemType theory = ItemType.CreateNewItem("theory1", "theory_id", null, PageType.Theory);

            this.organization.SubItems.Add(theory);

            Assert.IsFalse(SequencingPattern.AreAllChapters(organization));
        }
Пример #7
0
        public void AreAllPagesTest()
        {
            Assert.IsTrue(SequencingPattern.AreAllPages(this.chapter));

            ItemType theory  = ItemType.CreateNewItem("theory1", "theory_id", null, PageType.Theory);
            ItemType summary = ItemType.CreateNewItem("summary2", "theory2_id", null, PageType.Summary);

            this.chapter.SubItems.Add(theory);
            this.chapter.SubItems.Add(summary);

            Assert.IsTrue(SequencingPattern.AreAllPages(this.chapter));

            this.chapter.SubItems.Add(this.controlChapter);

            Assert.IsFalse(SequencingPattern.AreAllPages(this.chapter));
        }
Пример #8
0
        private ItemType CreateNewItem([NotNull] PageType pageType)
        {
            var title    = ConfigHelper.GetDefaultItemTitle(pageType);
            var resIdn   = IdGenerator.GenerateUniqueFileName(title, ".html", Course.FullPath);
            var resource = new ResourceType(resIdn, "webcontent", pageType, resIdn + ".html");

            Course.Manifest.resources.Resources.Add(resource);

            if (pageType == PageType.Question)
            {
                string depId = "ExaminationDependency";


                if (Course.Manifest.resources[depId] == null)
                {
                    var depRes = new ResourceType(depId, "webcontent", PageType.Theory, null);

                    depRes.file.Clear();

                    foreach (string href in HtmlPageBase.__NeededScripts)
                    {
                        depRes.file.Add(new FileType(href));
                    }
                    foreach (string href in HtmlPageBase.__NeededFiles)
                    {
                        depRes.file.Add(new FileType(href));
                    }
                    Course.Manifest.resources.Resources.Add(depRes);
                }

                DependencyType dep = new DependencyType();
                dep.identifierref = depId;

                resource.dependency.Add(dep);
            }


            var node       = (IItemContainer)tvItems.SelectedNode.Tag;
            var resultItem = ItemType.CreateNewItem(title, resIdn, resIdn, pageType);

            node.SubItems.Add(resultItem);



            return(resultItem);
        }
Пример #9
0
        private void InsertGroupingItem(PageType pageType)
        {
            var           treeNode = tvItems.SelectedNode;
            var           manNode  = treeNode.Tag as IManifestNode;
            IManifestNode n;

            if ((manNode is IItemContainer) == false)
            {
                return;
            }

            var newItem = ItemType.CreateNewItem(String.Format("New Grouping {0}", pageType), Guid.NewGuid().ToString(), string.Empty, pageType);

            n = newItem;
            (manNode as IItemContainer).InsertGroupingItem(newItem);
            tvItems.SelectedNode = treeNode.Nodes.Find(n.UID, true)[0];

            treeNode = treeNode.Nodes.Find(n.UID, true)[0];
            treeNode.BeginEdit();
        }
Пример #10
0
        public void InsertGroupingChapter_SubItemsTest()
        {
            ItemType item1 = ItemType.CreateNewItem("Item1", "Item1", null, PageType.Chapter);
            ItemType item2 = ItemType.CreateNewItem("Item2", "Item2", null, PageType.ControlChapter);

            this.item.SubItems.Add(item1);
            this.item.SubItems.Add(item2);

            Assert.AreEqual(2, this.item.SubItems.Count);

            ItemType groupingItem = ItemType.CreateNewItem("ItemG", "ItemG", null, PageType.Chapter);

            groupingItem.Parent = groupingItem;

            this.item.InsertGroupingItem(groupingItem);

            Assert.AreEqual(1, this.item.SubItems.Count);
            Assert.AreSame(groupingItem, this.item.SubItems[0]);
            Assert.AreEqual(2, this.item.SubItems[0].SubItems.Count);
        }
Пример #11
0
        public void SettingUp()
        {
            this.chapterItem        = ItemType.CreateNewItem("chapter item", "ci", null, PageType.Chapter);
            this.controlChapterItem = ItemType.CreateNewItem("controlChapter item", "cci", "ewrt", PageType.ControlChapter);
            this.theoryItem         = ItemType.CreateNewItem("theory item", "ti", "dsfg", PageType.Theory);
            // this.questionItem = ItemType.CreateNewItem("question item", "qi", "rtwret", PageType.Question);
            this.summaryItem = ItemType.CreateNewItem("summary item", "si", "ywwdfg", PageType.Summary);
            this.unknownItem = ItemType.CreateNewItem("unknown item", "ui", "wettw", PageType.Unknown);

            this.items = new List <ItemType>();
            this.items.Add(chapterItem);
            this.items.Add(controlChapterItem);
            this.items.Add(theoryItem);
            // this.items.Add(questionItem);
            this.items.Add(summaryItem);
            this.items.Add(unknownItem);

            this.sequencing = new SequencingType();

            this.organization = new OrganizationType();
        }
Пример #12
0
        public void RemoveAndMerge_SubItemsTest()
        {
            //Chapter1 to remove.
            ItemType chapter1 = ItemType.CreateNewItem("Chapter1", "Chapter1", null, PageType.Chapter);
            ItemType item0    = ItemType.CreateNewItem("Item0", "Item0", null, PageType.Theory);
            //Items to merge.
            ItemType item1 = ItemType.CreateNewItem("SubItem1", "SubItem1", null, PageType.Theory);
            ItemType item2 = ItemType.CreateNewItem("SubItem2", "SubItem2", null, PageType.Chapter);

            this.item.SubItems.Add(chapter1);
            this.item.SubItems.Add(item0);
            chapter1.SubItems.Add(item1);
            chapter1.SubItems.Add(item2);
            //Structure will look like this:
            //Test Item 1
            //  Chapter1
            //    SubItem1
            //    SubItem2
            //  Item0

            Assert.AreEqual(2, this.item.SubItems.Count);
            Assert.AreEqual(2, chapter1.SubItems.Count);
            Assert.IsTrue(this.item.SubItems[0].SubItems[0].IsLeaf);
            Assert.IsTrue(this.item.SubItems[0].SubItems[1].IsLeaf);
            Assert.IsTrue(this.item.SubItems[1].IsLeaf);

            Assert.AreSame(chapter1, this.item.SubItems[0]);

            this.item.SubItems[0].RemoveAndMerge();

            Assert.AreEqual(3, this.item.SubItems.Count);
            Assert.IsTrue(this.item.SubItems[0].IsLeaf);
            Assert.IsTrue(this.item.SubItems[1].IsLeaf);
            Assert.IsTrue(this.item.SubItems[2].IsLeaf);

            Assert.IsTrue(this.item.SubItems.Contains(item0));
            Assert.IsTrue(this.item.SubItems.Contains(item1));
            Assert.IsTrue(this.item.SubItems.Contains(item2));
        }
Пример #13
0
        public void CheckForLeafChapterTest()
        {
            Assert.AreEqual(true, this.item.CheckForLeafChapter());
            Assert.Greater(this.item.Errors.Count, 0);

            ItemType item1 = ItemType.CreateNewItem("Item1", "Item1", null, PageType.Chapter);
            ItemType item2 = ItemType.CreateNewItem("Item2", "Item2", null, PageType.Theory);

            this.item.SubItems.Add(item1);
            Assert.AreEqual(false, this.item.CheckForLeafChapter());
            Assert.AreEqual(0, this.item.Errors.Count);

            this.item.RemoveChild(item1);

            this.item.SubItems.Add(item2);
            Assert.AreEqual(false, this.item.CheckForLeafChapter());
            Assert.AreEqual(0, this.item.Errors.Count);

            ItemType leafTheory = ItemType.CreateNewItem("Chapter", "Item3", null, PageType.Theory);

            Assert.AreEqual(false, leafTheory.CheckForLeafChapter());
        }
Пример #14
0
 public void SetUp()
 {
     this.item = ItemType.CreateNewItem("Test Item 1", "Test_Item_1_id", null, PageType.Chapter);
 }