public void Constructor1_Deny_Unrestricted()
        {
            CodeCommentStatementCollection coll = new CodeCommentStatementCollection(array);

            coll.CopyTo(array, 0);
            Assert.AreEqual(1, coll.Add(ccs), "Add");
            Assert.AreSame(ccs, coll[0], "this[int]");
            coll.AddRange(array);
            coll.AddRange(coll);
            Assert.IsTrue(coll.Contains(ccs), "Contains");
            Assert.AreEqual(0, coll.IndexOf(ccs), "IndexOf");
            coll.Insert(0, ccs);
            coll.Remove(ccs);
        }
Beispiel #2
0
        public void Remove()
        {
            CodeCommentStatement ccs1 = new CodeCommentStatement();
            CodeCommentStatement ccs2 = new CodeCommentStatement();

            CodeCommentStatementCollection coll = new CodeCommentStatementCollection();

            coll.Add(ccs1);
            coll.Add(ccs2);
            Assert.AreEqual(2, coll.Count, "#1");
            Assert.AreEqual(0, coll.IndexOf(ccs1), "#2");
            Assert.AreEqual(1, coll.IndexOf(ccs2), "#3");
            coll.Remove(ccs1);
            Assert.AreEqual(1, coll.Count, "#4");
            Assert.AreEqual(-1, coll.IndexOf(ccs1), "#5");
            Assert.AreEqual(0, coll.IndexOf(ccs2), "#6");
        }
Beispiel #3
0
        public void Remove_Null()
        {
            CodeCommentStatementCollection coll = new CodeCommentStatementCollection();

            coll.Remove((CodeCommentStatement)null);
        }
Beispiel #4
0
        public void Remove_NotInCollection()
        {
            CodeCommentStatementCollection coll = new CodeCommentStatementCollection();

            coll.Remove(new CodeCommentStatement());
        }
Beispiel #5
0
        // CodeCommentStatementCollection
        public void CodeCommentStatementCollectionExample()
        {
            //<Snippet1>
            //<Snippet2>
            // Creates an empty CodeCommentStatementCollection.
            CodeCommentStatementCollection collection = new CodeCommentStatementCollection();

            //</Snippet2>

            //<Snippet3>
            // Adds a CodeCommentStatement to the collection.
            collection.Add(new CodeCommentStatement("Test comment"));
            //</Snippet3>

            //<Snippet4>
            // Adds an array of CodeCommentStatement objects to the collection.
            CodeCommentStatement[] comments = { new CodeCommentStatement("Test comment"), new CodeCommentStatement("Another test comment") };
            collection.AddRange(comments);

            // Adds a collection of CodeCommentStatement objects to the collection.
            CodeCommentStatementCollection commentsCollection = new CodeCommentStatementCollection();

            commentsCollection.Add(new CodeCommentStatement("Test comment"));
            commentsCollection.Add(new CodeCommentStatement("Another test comment"));
            collection.AddRange(commentsCollection);
            //</Snippet4>

            //<Snippet5>
            // Tests for the presence of a CodeCommentStatement in the
            // collection, and retrieves its index if it is found.
            CodeCommentStatement testComment = new CodeCommentStatement("Test comment");
            int itemIndex = -1;

            if (collection.Contains(testComment))
            {
                itemIndex = collection.IndexOf(testComment);
            }
            //</Snippet5>

            //<Snippet6>
            // Copies the contents of the collection, beginning at index 0,
            // to the specified CodeCommentStatement array.
            // 'comments' is a CodeCommentStatement array.
            collection.CopyTo(comments, 0);
            //</Snippet6>

            //<Snippet7>
            // Retrieves the count of the items in the collection.
            int collectionCount = collection.Count;

            //</Snippet7>

            //<Snippet8>
            // Inserts a CodeCommentStatement at index 0 of the collection.
            collection.Insert(0, new CodeCommentStatement("Test comment"));
            //</Snippet8>

            //<Snippet9>
            // Removes the specified CodeCommentStatement from the collection.
            CodeCommentStatement comment = new CodeCommentStatement("Test comment");

            collection.Remove(comment);
            //</Snippet9>

            //<Snippet10>
            // Removes the CodeCommentStatement at index 0.
            collection.RemoveAt(0);
            //</Snippet10>
            //</Snippet1>
        }