コード例 #1
0
        public TermUploader(LocalTerm localTerm, UploadController controller)
            : base(controller)
        {
            this.localTerm = localTerm;

            if (this.localTerm.IsPinnedRoot)
            {
                throw new NotImplementedException("The IsPinnedRoot attribute is not implemented yet");
            }
        }
コード例 #2
0
        public void CustomSortOrderParsingForServer()
        {
            var localTerm = LocalTerm.CreateTerm(new Guid("11111111-2222-3333-4444-000000000001"), "Term", 1033);

            localTerm.CustomSortOrder.AsTextForServer =
                " 11111111-2222-3333-4444-000000000001"
                + ":11111111-2222-3333-4444-000000000002"
                + ":: hello, world!"
                + ":11111111-2222-3333-4444-000000000003 "
                + ":11111111-2222-3333-4444-000000000004"
                + ":11111111-2222-3333-4444-000000000003 ";
            localTerm.CustomSortOrder.Insert(0, new Guid("11111111-2222-3333-4444-000000000005"));

            Assert.AreEqual(localTerm.CustomSortOrder.Count, 5);

            Assert.AreEqual(localTerm.CustomSortOrder.AsText,
                            "11111111-2222-3333-4444-000000000005"
                            + ":11111111-2222-3333-4444-000000000001"
                            + ":11111111-2222-3333-4444-000000000002"
                            + ":11111111-2222-3333-4444-000000000003"
                            + ":11111111-2222-3333-4444-000000000004"
                            );

            try
            {
                localTerm.CustomSortOrder.Add(new Guid("11111111-2222-3333-4444-000000000005"));
                Assert.Fail("Exception not thrown");
            }
            catch (Exception ex)
            {
                Assert.AreEqual(ex.GetType(), typeof(ArgumentException));
                Assert.AreEqual(localTerm.CustomSortOrder.Count, 5);
            }

            localTerm.CustomSortOrder.Clear();

            Assert.AreEqual(localTerm.CustomSortOrder.AsText, "");
        }
コード例 #3
0
        protected override void AssignChildObjects()
        {
            foreach (Term childClientTerm in this.ClientObject.Terms)
            {
                var termDownloader = new TermDownloader(this.DownloaderContext, childClientTerm, this.TreeDepth + 1);
                termDownloader.AssignMinimalProperties();

                LocalTerm childLocalTerm = termDownloader.LocalObject;
                this.LocalObject.AddTerm(childLocalTerm);

                if (this.ShouldRecurse)
                {
                    string indent = "";
                    for (int i = 0; i < this.TreeDepth - 1; ++i)
                    {
                        indent += "    ";
                    }
                    Debug.WriteLine(indent + "--> Fetching children for term: " + childLocalTerm.ToString());

                    termDownloader.FetchItem();
                }
            }
        }
コード例 #4
0
        public void CustomSortOrderParsing()
        {
            var localTerm = LocalTerm.CreateTerm(new Guid("11111111-2222-3333-4444-000000000001"), "Term", 1033);

            localTerm.CustomSortOrder.AsText =
                " 11111111-2222-3333-4444-000000000001"
                + ":11111111-2222-3333-4444-000000000002"
                + ":11111111-2222-3333-4444-000000000003 ";
            localTerm.CustomSortOrder.Insert(0, new Guid("11111111-2222-3333-4444-000000000004"));

            Assert.AreEqual(localTerm.CustomSortOrder.Count, 4);

            Assert.AreEqual(localTerm.CustomSortOrder.AsText,
                            "11111111-2222-3333-4444-000000000004"
                            + ":11111111-2222-3333-4444-000000000001"
                            + ":11111111-2222-3333-4444-000000000002"
                            + ":11111111-2222-3333-4444-000000000003"
                            );

            localTerm.CustomSortOrder.Clear();

            Assert.AreEqual(localTerm.CustomSortOrder.AsText, "");
        }
コード例 #5
0
        public void SiblingTermNameConflictsWhenRenaming()
        {
            var guids = new Guid[] {
                new Guid("ff000000-0000-0000-0000-000000000000"),
                new Guid("ff000000-0000-0000-0000-000000000001"),
                new Guid("ff000000-0000-0000-0000-000000000002"),
                new Guid("ff000000-0000-0000-0000-000000000003"),
                new Guid("ff000000-0000-0000-0000-000000000004")
            };

            var termStore = new LocalTermStore(guids[0], "MMS", 1030);

            termStore.SetAvailableLanguageLcids(new[] { 1030, 1031, 1033 });

            var termGroup = termStore.AddTermGroup(guids[1], "Group");
            var termSet   = termGroup.AddTermSet(guids[2], "TermSet");

            // Synonyms (i.e. non-default labels) cannot conflict with each other
            var term1 = LocalTerm.CreateTerm(guids[3], "Apple", 1030);

            termSet.AddTerm(term1);

            var term2 = LocalTerm.CreateTerm(guids[4], "Banana", 1030);

            termSet.AddTerm(term2);

            try
            {
                term2.Name = "Apple";
                Assert.Fail("Exception not thrown");
            }
            catch (Exception ex)
            {
                Assert.AreEqual(ex.Message, "The term name \"Apple\" is already in use by a sibling term (LCID=1030)");
                Assert.AreEqual(term2.Name, "Banana"); // term2 should not have been changed
            }
        }
コード例 #6
0
        public void DefaultLanguageMismatch()
        {
            var guids = new Guid[] {
                new Guid("ff000000-0000-0000-0000-000000000000"),
                new Guid("ff000000-0000-0000-0000-000000000001")
            };

            LocalTerm term0 = LocalTerm.CreateTerm(guids[0], "Name", 1030);
            LocalTerm term1 = LocalTerm.CreateTerm(guids[1], "Name", 1031);

            Assert.AreEqual(term0.DefaultLanguageLcid, 1030);
            Assert.AreEqual(term1.DefaultLanguageLcid, 1031);

            try
            {
                // should throw because the parent's default language doesn't match
                term1.ParentItem = term0;
                Assert.Fail("Exception not thrown");
            }
            catch (Exception ex)
            {
                Assert.AreEqual(ex.GetType(), typeof(InvalidOperationException));
            }
        }
コード例 #7
0
        public void SiblingTermNameConflictsWhenAdding()
        {
            var guids = new Guid[] {
                new Guid("ff000000-0000-0000-0000-000000000000"),
                new Guid("ff000000-0000-0000-0000-000000000001"),
                new Guid("ff000000-0000-0000-0000-000000000002"),
                new Guid("ff000000-0000-0000-0000-000000000003"),
                new Guid("ff000000-0000-0000-0000-000000000004"),
                new Guid("ff000000-0000-0000-0000-000000000005"),
                new Guid("ff000000-0000-0000-0000-000000000006"),
                new Guid("ff000000-0000-0000-0000-000000000007"),
                new Guid("ff000000-0000-0000-0000-000000000008")
            };

            var termStore = new LocalTermStore(guids[0], "MMS", 1030);

            termStore.SetAvailableLanguageLcids(new[] { 1030, 1031, 1033 });

            var termGroup = termStore.AddTermGroup(guids[1], "Group");
            var termSet   = termGroup.AddTermSet(guids[2], "TermSet");

            // Synonyms (i.e. non-default labels) cannot conflict with each other
            var term1 = LocalTerm.CreateTerm(guids[3], "Apple", 1030);

            term1.AddLabel("No Conflict", 1030, setAsDefaultLabel: false);
            termSet.AddTerm(term1);

            var term2 = LocalTerm.CreateTerm(guids[4], "Banana", 1030);

            term2.AddLabel("No Conflict", 1030, setAsDefaultLabel: false);
            termSet.AddTerm(term2);

            // Default labels do not conflict unless the language is the same
            var term3 = LocalTerm.CreateTerm(guids[5], "Coconut", 1030);

            term3.SetName("Durian", 1033);
            termSet.AddTerm(term3);

            var term4 = LocalTerm.CreateTerm(guids[6], "Durian", 1030);

            term4.SetName("Coconut", 1033);
            termSet.AddTerm(term4);

            // Default labels do conflict if the language is the same
            // failedTerm5 should conflict with term3
            var failedTerm5 = LocalTerm.CreateTerm(guids[7], "Elderberry", 1030);

            failedTerm5.SetName("Durian", 1033);
            try
            {
                termSet.AddTerm(failedTerm5);
                Assert.Fail("Exception not thrown");
            }
            catch (Exception ex)
            {
                Assert.AreEqual(ex.Message, "The term name \"Durian\" is already in use by a sibling term (LCID=1033)");
                Assert.AreEqual(termSet.Terms.Count, 4); // failedTerm5 should not have been added
            }

            // If a default label is missing for one of the LCIDs, we fallback to the default language,
            // which can cause a conflict
            var term5 = LocalTerm.CreateTerm(guids[7], "Feijoa", 1030);

            term5.SetName("Guava", 1031);
            termSet.AddTerm(term5);

            // failedTerm6 should conflict with term5 because for LCID=1031, it will fallback to use
            // the default language which is "Guava"
            var failedTerm6 = LocalTerm.CreateTerm(guids[8], "Guava", 1030);

            try
            {
                termSet.AddTerm(failedTerm6);
                Assert.Fail("Exception not thrown");
            }
            catch (Exception ex)
            {
                Assert.AreEqual(ex.Message, "The term name \"Guava\" is already in use by a sibling term (LCID=1031)");
                Assert.IsNull(failedTerm6.ParentItem); // failedTerm6 should not have been added
            }
        }