public void Constructor1_Deny_Unrestricted() { CodeAttributeArgumentCollection coll = new CodeAttributeArgumentCollection(array); coll.CopyTo(array, 0); Assert.AreEqual(1, coll.Add(caa), "Add"); Assert.AreSame(caa, coll[0], "this[int]"); coll.AddRange(array); coll.AddRange(coll); Assert.IsTrue(coll.Contains(caa), "Contains"); Assert.AreEqual(0, coll.IndexOf(caa), "IndexOf"); coll.Insert(0, caa); coll.Remove(caa); }
public void Remove() { CodeAttributeArgument caa1 = new CodeAttributeArgument(); CodeAttributeArgument caa2 = new CodeAttributeArgument(); CodeAttributeArgumentCollection coll = new CodeAttributeArgumentCollection(); coll.Add(caa1); coll.Add(caa2); Assert.AreEqual(2, coll.Count, "#1"); Assert.AreEqual(0, coll.IndexOf(caa1), "#2"); Assert.AreEqual(1, coll.IndexOf(caa2), "#3"); coll.Remove(caa1); Assert.AreEqual(1, coll.Count, "#4"); Assert.AreEqual(-1, coll.IndexOf(caa1), "#5"); Assert.AreEqual(0, coll.IndexOf(caa2), "#6"); }
// CodeAttributeArgumentCollection public void CodeAttributeArgumentCollectionExample() { //<Snippet1> //<Snippet2> // Creates an empty CodeAttributeArgumentCollection. CodeAttributeArgumentCollection collection = new CodeAttributeArgumentCollection(); //</Snippet2> //<Snippet3> // Adds a CodeAttributeArgument to the collection. collection.Add(new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true))); //</Snippet3> //<Snippet4> // Adds an array of CodeAttributeArgument objects to the collection. CodeAttributeArgument[] arguments = { new CodeAttributeArgument(), new CodeAttributeArgument() }; collection.AddRange(arguments); // Adds a collection of CodeAttributeArgument objects to // the collection. CodeAttributeArgumentCollection argumentsCollection = new CodeAttributeArgumentCollection(); argumentsCollection.Add(new CodeAttributeArgument("TestBooleanArgument", new CodePrimitiveExpression(true))); argumentsCollection.Add(new CodeAttributeArgument("TestIntArgument", new CodePrimitiveExpression(1))); collection.AddRange(argumentsCollection); //</Snippet4> //<Snippet5> // Tests for the presence of a CodeAttributeArgument // within the collection, and retrieves its index if it is found. CodeAttributeArgument testArgument = new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true)); int itemIndex = -1; if (collection.Contains(testArgument)) { itemIndex = collection.IndexOf(testArgument); } //</Snippet5> //<Snippet6> // Copies the contents of the collection beginning at index 0, // to the specified CodeAttributeArgument array. // 'arguments' is a CodeAttributeArgument array. collection.CopyTo(arguments, 0); //</Snippet6> //<Snippet7> // Retrieves the count of the items in the collection. int collectionCount = collection.Count; //</Snippet7> //<Snippet8> // Inserts a CodeAttributeArgument at index 0 of the collection. collection.Insert(0, new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true))); //</Snippet8> //<Snippet9> // Removes the specified CodeAttributeArgument from the collection. CodeAttributeArgument argument = new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true)); collection.Remove(argument); //</Snippet9> //<Snippet10> // Removes the CodeAttributeArgument at index 0. collection.RemoveAt(0); //</Snippet10> //</Snippet1> }
public void Remove_Null() { CodeAttributeArgumentCollection coll = new CodeAttributeArgumentCollection(); coll.Remove((CodeAttributeArgument)null); }
public void Remove_NotInCollection() { CodeAttributeArgumentCollection coll = new CodeAttributeArgumentCollection(); coll.Remove(new CodeAttributeArgument()); }