public IndexOf ( |
||
value | ||
리턴 | int |
public void Constructor1 () { CodeAttributeDeclaration cad1 = new CodeAttributeDeclaration (); CodeAttributeDeclaration cad2 = new CodeAttributeDeclaration (); CodeAttributeDeclaration[] declarations = new CodeAttributeDeclaration[] { cad1, cad2 }; CodeAttributeDeclarationCollection coll = new CodeAttributeDeclarationCollection ( declarations); Assert.AreEqual (2, coll.Count, "#1"); Assert.AreEqual (0, coll.IndexOf (cad1), "#2"); Assert.AreEqual (1, coll.IndexOf (cad2), "#3"); }
public void Constructor0_Deny_Unrestricted () { CodeAttributeDeclarationCollection coll = new CodeAttributeDeclarationCollection (); Assert.AreEqual (0, coll.Add (cad), "Add"); Assert.AreSame (cad, coll[0], "this[int]"); coll.CopyTo (array, 0); coll.AddRange (array); coll.AddRange (coll); Assert.IsTrue (coll.Contains (cad), "Contains"); Assert.AreEqual (0, coll.IndexOf (cad), "IndexOf"); coll.Insert (0, cad); coll.Remove (cad); }
public void Constructor2 () { CodeAttributeDeclaration cad1 = new CodeAttributeDeclaration (); CodeAttributeDeclaration cad2 = new CodeAttributeDeclaration (); CodeAttributeDeclarationCollection c = new CodeAttributeDeclarationCollection (); c.Add (cad1); c.Add (cad2); CodeAttributeDeclarationCollection coll = new CodeAttributeDeclarationCollection (c); Assert.AreEqual (2, coll.Count, "#1"); Assert.AreEqual (0, coll.IndexOf (cad1), "#2"); Assert.AreEqual (1, coll.IndexOf (cad2), "#3"); }
public void Remove () { CodeAttributeDeclaration cad1 = new CodeAttributeDeclaration (); CodeAttributeDeclaration cad2 = new CodeAttributeDeclaration (); CodeAttributeDeclarationCollection coll = new CodeAttributeDeclarationCollection (); coll.Add (cad1); coll.Add (cad2); Assert.AreEqual (2, coll.Count, "#1"); Assert.AreEqual (0, coll.IndexOf (cad1), "#2"); Assert.AreEqual (1, coll.IndexOf (cad2), "#3"); coll.Remove (cad1); Assert.AreEqual (1, coll.Count, "#4"); Assert.AreEqual (-1, coll.IndexOf (cad1), "#5"); Assert.AreEqual (0, coll.IndexOf (cad2), "#6"); }
public void AddRange () { CodeAttributeDeclaration cad1 = new CodeAttributeDeclaration (); CodeAttributeDeclaration cad2 = new CodeAttributeDeclaration (); CodeAttributeDeclaration cad3 = new CodeAttributeDeclaration (); CodeAttributeDeclarationCollection coll1 = new CodeAttributeDeclarationCollection (); coll1.Add (cad1); coll1.Add (cad2); CodeAttributeDeclarationCollection coll2 = new CodeAttributeDeclarationCollection (); coll2.Add (cad3); coll2.AddRange (coll1); Assert.AreEqual (3, coll2.Count, "#1"); Assert.AreEqual (1, coll2.IndexOf (cad1), "#2"); Assert.AreEqual (2, coll2.IndexOf (cad2), "#3"); Assert.AreEqual (0, coll2.IndexOf (cad3), "#4"); CodeAttributeDeclarationCollection coll3 = new CodeAttributeDeclarationCollection (); coll3.Add (cad3); coll3.AddRange (new CodeAttributeDeclaration[] { cad1, cad2 }); Assert.AreEqual (3, coll2.Count, "#5"); Assert.AreEqual (1, coll2.IndexOf (cad1), "#6"); Assert.AreEqual (2, coll2.IndexOf (cad2), "#7"); Assert.AreEqual (0, coll2.IndexOf (cad3), "#8"); }