當前位置: 首頁>>代碼示例>>C#>>正文


C# AnItem.AddTo方法代碼示例

本文整理匯總了C#中AnItem.AddTo方法的典型用法代碼示例。如果您正苦於以下問題:C# AnItem.AddTo方法的具體用法?C# AnItem.AddTo怎麽用?C# AnItem.AddTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AnItem的用法示例。


在下文中一共展示了AnItem.AddTo方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AddTo_CanBeAddedToNull

        public void AddTo_CanBeAddedToNull()
        {
            AnItem parent = new AnItem();
            AnItem child = new AnItem();

            child.AddTo(parent);
            Assert.AreEqual(parent, child.Parent);
            EnumerableAssert.Contains(parent.Children, child);

            child.AddTo(null);
            Assert.IsNull(child.Parent);
            EnumerableAssert.DoesntContain(parent.Children, child);
        }
開發者ID:spmason,項目名稱:n2cms,代碼行數:13,代碼來源:ContentItemTests.cs

示例2: AddTo_IsRemovedFrom_PreviousParentChildren

        public void AddTo_IsRemovedFrom_PreviousParentChildren()
        {
            AnItem parent1 = new AnItem();
            AnItem parent2 = new AnItem();
            AnItem child = new AnItem();

            child.AddTo(parent1);
            EnumerableAssert.Contains(parent1.Children, child);
            EnumerableAssert.DoesntContain(parent2.Children, child);

            child.AddTo(parent2);
            EnumerableAssert.DoesntContain(parent1.Children, child);
            EnumerableAssert.Contains(parent2.Children, child);
        }
開發者ID:brianmatic,項目名稱:n2cms,代碼行數:14,代碼來源:ContentItemTests.cs

示例3: AddTo_IsAddedToChildren

        public void AddTo_IsAddedToChildren()
        {
            AnItem parent = new AnItem();
            AnItem child = new AnItem();

            child.AddTo(parent);
            EnumerableAssert.Contains(parent.Children, child);
        }
開發者ID:brianmatic,項目名稱:n2cms,代碼行數:8,代碼來源:ContentItemTests.cs

示例4: AddTo_UpdatesParentRelation

        public void AddTo_UpdatesParentRelation()
        {
            AnItem parent = new AnItem();
            AnItem child = new AnItem();

            child.AddTo(parent);
            Assert.AreEqual(parent, child.Parent);
        }
開發者ID:brianmatic,項目名稱:n2cms,代碼行數:8,代碼來源:ContentItemTests.cs

示例5: AddsToChildrenWhenOnlyParentIsSet

        public void AddsToChildrenWhenOnlyParentIsSet()
        {
            AnItem parent = new AnItem();
            AnItem child = new AnItem();

            child.Parent = parent;

            child.AddTo(parent);
            EnumerableAssert.Contains(parent.Children, child);
        }
開發者ID:spmason,項目名稱:n2cms,代碼行數:10,代碼來源:ContentItemTests.cs

示例6: AddTo_IsAppendedLast

        public void AddTo_IsAppendedLast()
        {
            AnItem parent = new AnItem();
            AnItem child1 = new AnItem();
            AnItem child2 = new AnItem();
            AnItem child3 = new AnItem();
            AnItem child4 = new AnItem();

            child1.AddTo(parent);
            child2.AddTo(parent);
            child3.AddTo(parent);
            child4.AddTo(parent);

            Assert.AreEqual(child1, parent.Children[0]);
            Assert.AreEqual(child2, parent.Children[1]);
            Assert.AreEqual(child3, parent.Children[2]);
            Assert.AreEqual(child4, parent.Children[3]);
        }
開發者ID:spmason,項目名稱:n2cms,代碼行數:18,代碼來源:ContentItemTests.cs

示例7: AddTo_IsAppendedLast_EvenWhenSortOrder_MayIndicateOtherwise

        public void AddTo_IsAppendedLast_EvenWhenSortOrder_MayIndicateOtherwise()
        {
            AnItem parent = new AnItem();
            AnItem child1 = new AnItem();
            child1.SortOrder = 4;
            AnItem child2 = new AnItem();
            child2.SortOrder = 3;
            AnItem child3 = new AnItem();
            child3.SortOrder = 2;
            AnItem child4 = new AnItem();
            child4.SortOrder = 1;

            child1.AddTo(parent);
            child2.AddTo(parent);
            child3.AddTo(parent);
            child4.AddTo(parent);

            Assert.AreEqual(child1, parent.Children[0]);
            Assert.AreEqual(child2, parent.Children[1]);
            Assert.AreEqual(child3, parent.Children[2]);
            Assert.AreEqual(child4, parent.Children[3]);
        }
開發者ID:spmason,項目名稱:n2cms,代碼行數:22,代碼來源:ContentItemTests.cs

示例8: DoesntAddToChildrenTwice

        public void DoesntAddToChildrenTwice()
        {
            AnItem parent = new AnItem();
            AnItem child = new AnItem();

            parent.Children.Add(child);

            child.AddTo(parent);
            Assert.AreEqual(parent, child.Parent);
            Assert.AreEqual(1, parent.Children.Count);
        }
開發者ID:jhang,項目名稱:n2cms,代碼行數:11,代碼來源:ContentItemTests.cs


注:本文中的AnItem.AddTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。