2 // ComboBoxTest.cs: Test cases for ComboBox.
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
26 // Ritvik Mayank <mritvik@novell.com>
27 // Jordi Mas i Hernandez <jordi@ximian.com>
31 using System.Collections;
32 using System.ComponentModel;
34 using System.Reflection;
35 using System.Windows.Forms;
37 using NUnit.Framework;
39 namespace MonoTests.System.Windows.Forms
42 public class ListBoxTest : TestHelper
48 protected override void SetUp ()
50 listBox = new ListBox();
52 form.ShowInTaskbar = false;
57 protected override void TearDown ()
64 public void RemoveLast ()
66 listBox.Items.Clear ();
68 for (int i = 0; i < 3; i++)
69 listBox.Items.Add (i.ToString ());
71 // need to create control to actually test the invalidation
72 listBox.CreateControl ();
74 // select last - then remove an item that is *not* the last,
75 // so basically the selection is invalidated implicitly
76 listBox.SelectedIndex = 2;
77 listBox.Items.RemoveAt (1);
78 Assert.AreEqual (1, listBox.SelectedIndex, "#A1");
80 listBox.SelectedIndex = 0;
81 Assert.AreEqual (0, listBox.SelectedIndex, "#B1");
86 listBox.ClearSelected ();
87 listBox.Items.Clear ();
88 for (int i = 0; i < 3; i++)
89 listBox.Items.Add (i.ToString ());
91 listBox.SelectionMode = SelectionMode.MultiSimple;
93 listBox.SetSelected (0, true);
94 listBox.SetSelected (2, true);
96 Assert.AreEqual (true, listBox.GetSelected (0), "#C1");
97 Assert.AreEqual (false, listBox.GetSelected (1), "#C2");
98 Assert.AreEqual (true, listBox.GetSelected (2), "#C3");
100 listBox.Items.RemoveAt (2);
101 Assert.AreEqual (true, listBox.GetSelected (0), "#D1");
102 Assert.AreEqual (false, listBox.GetSelected (1), "#D2");
103 Assert.AreEqual (1, listBox.SelectedIndices.Count, "#D3");
107 public void ListBoxPropertyTest ()
109 Assert.AreEqual (0, listBox.ColumnWidth, "#1");
110 Assert.AreEqual (DrawMode.Normal, listBox.DrawMode, "#2");
111 Assert.AreEqual (0, listBox.HorizontalExtent, "#3");
112 Assert.AreEqual (false, listBox.HorizontalScrollbar, "#4");
113 Assert.AreEqual (true, listBox.IntegralHeight, "#5");
114 //Assert.AreEqual (13, listBox.ItemHeight, "#6"); // Note: Item height depends on the current font.
115 listBox.Items.Add ("a");
116 listBox.Items.Add ("b");
117 listBox.Items.Add ("c");
118 Assert.AreEqual (3, listBox.Items.Count, "#7");
119 Assert.AreEqual (false, listBox.MultiColumn, "#8");
120 //Assert.AreEqual (46, listBox.PreferredHeight, "#9"); // Note: Item height depends on the current font.
121 //Assert.AreEqual (RightToLeft.No , listBox.RightToLeft, "#10"); // Depends on Windows version
122 Assert.AreEqual (false, listBox.ScrollAlwaysVisible, "#11");
123 Assert.AreEqual (-1, listBox.SelectedIndex, "#12");
124 listBox.SetSelected (2,true);
125 Assert.AreEqual (2, listBox.SelectedIndices[0], "#13");
126 Assert.AreEqual ("c", listBox.SelectedItem, "#14");
127 Assert.AreEqual ("c", listBox.SelectedItems[0], "#15");
128 Assert.AreEqual (SelectionMode.One, listBox.SelectionMode, "#16");
129 listBox.SetSelected (2,false);
130 Assert.AreEqual (false, listBox.Sorted, "#17");
131 Assert.AreEqual ("", listBox.Text, "#18");
132 Assert.AreEqual (0, listBox.TopIndex, "#19");
133 Assert.AreEqual (true, listBox.UseTabStops, "#20");
137 public void BeginEndUpdateTest ()
140 listBox.Items.Add ("A");
141 listBox.Visible = true;
142 form.Controls.Add (listBox);
143 listBox.BeginUpdate ();
144 for (int x = 1; x < 5000; x++)
146 listBox.Items.Add ("Item " + x.ToString ());
148 listBox.EndUpdate ();
149 listBox.SetSelected (1, true);
150 listBox.SetSelected (3, true);
151 Assert.AreEqual (true, listBox.SelectedItems.Contains ("Item 3"), "#21");
155 public void ClearSelectedTest ()
158 listBox.Items.Add ("A");
159 listBox.Visible = true;
160 form.Controls.Add (listBox);
161 listBox.SetSelected (0, true);
162 Assert.AreEqual ("A", listBox.SelectedItems [0].ToString (),"#22");
163 listBox.ClearSelected ();
164 Assert.AreEqual (0, listBox.SelectedItems.Count,"#23");
168 [NUnit.Framework.Category ("NotWorking")]
169 public void ClientRectangle_Borders ()
171 // This test is invalid because createcontrol forces .net to resize
172 // the listbox using integralheight, which defaults to true. This
173 // will only hold for most font sizes.
174 listBox.CreateControl ();
175 Assert.AreEqual (listBox.ClientRectangle, new ListBox ().ClientRectangle);
178 [Ignore ("It depends on user system settings")]
179 public void GetItemHeightTest ()
181 listBox.Visible = true;
182 form.Controls.Add (listBox);
183 listBox.Items.Add ("A");
184 Assert.AreEqual (13, listBox.GetItemHeight (0) , "#28");
187 [Ignore ("It depends on user system settings")]
188 public void GetItemRectangleTest ()
191 listBox.Visible = true;
192 form.Controls.Add (listBox);
193 listBox.Items.Add ("A");
194 Assert.AreEqual (new Rectangle(0,0,116,13), listBox.GetItemRectangle (0), "#29");
198 public void GetSelectedTest ()
200 listBox.Items.Add ("A");
201 listBox.Items.Add ("B");
202 listBox.Items.Add ("C");
203 listBox.Items.Add ("D");
204 listBox.SelectionMode = SelectionMode.MultiSimple;
205 listBox.Sorted = true;
206 listBox.SetSelected (0,true);
207 listBox.SetSelected (2,true);
209 Assert.AreEqual (true, listBox.GetSelected (0), "#30");
210 listBox.SetSelected (2,false);
211 Assert.AreEqual (false, listBox.GetSelected (2), "#31");
215 public void IndexFromPointTest ()
217 listBox.Items.Add ("A");
218 Point pt = new Point (100,100);
219 listBox.IndexFromPoint (pt);
220 Assert.AreEqual (-1, listBox.IndexFromPoint (100,100), "#32");
224 public void FindStringTest ()
226 listBox.FindString ("Hola", -5); // No exception, it's empty
227 int x = listBox.FindString ("Hello");
228 Assert.AreEqual (-1, x, "#19");
229 listBox.Items.AddRange(new object[] {"ACBD", "ABDC", "ACBD", "ABCD"});
230 String myString = "ABC";
231 x = listBox.FindString (myString);
232 Assert.AreEqual (3, x, "#191");
233 x = listBox.FindString (string.Empty);
234 Assert.AreEqual (0, x, "#192");
235 x = listBox.FindString ("NonExistant");
236 Assert.AreEqual (-1, x, "#193");
238 x = listBox.FindString ("A", -1);
239 Assert.AreEqual (0, x, "#194");
240 x = listBox.FindString ("A", 0);
241 Assert.AreEqual (1, x, "#195");
242 x = listBox.FindString ("A", listBox.Items.Count - 1);
243 Assert.AreEqual (0, x, "#196");
244 x = listBox.FindString ("a", listBox.Items.Count - 1);
245 Assert.AreEqual (0, x, "#197");
249 public void FindStringExactTest ()
251 listBox.FindStringExact ("Hola", -5); // No exception, it's empty
252 int x = listBox.FindStringExact ("Hello");
253 Assert.AreEqual (-1, x, "#20");
254 listBox.Items.AddRange (new object[] {"ABCD","ABC","ABDC"});
255 String myString = "ABC";
256 x = listBox.FindStringExact (myString);
257 Assert.AreEqual (1, x, "#201");
258 x = listBox.FindStringExact (string.Empty);
259 Assert.AreEqual (-1, x, "#202");
260 x = listBox.FindStringExact ("NonExistant");
261 Assert.AreEqual (-1, x, "#203");
263 x = listBox.FindStringExact ("ABCD", -1);
264 Assert.AreEqual (0, x, "#204");
265 x = listBox.FindStringExact ("ABC", 0);
266 Assert.AreEqual (1, x, "#205");
267 x = listBox.FindStringExact ("ABC", listBox.Items.Count - 1);
268 Assert.AreEqual (1, x, "#206");
269 x = listBox.FindStringExact ("abcd", listBox.Items.Count - 1);
270 Assert.AreEqual (0, x, "#207");
275 public void AllowSelection ()
277 MockListBox lb = new MockListBox ();
278 lb.SelectionMode = SelectionMode.None;
279 Assert.IsFalse (lb.allow_selection, "#1");
280 lb.SelectionMode = SelectionMode.One;
281 Assert.IsTrue (lb.allow_selection, "#2");
290 [ExpectedException (typeof (InvalidEnumArgumentException))]
291 public void BorderStyleException ()
293 listBox.BorderStyle = (BorderStyle) 10;
297 [ExpectedException (typeof (ArgumentException))]
298 public void ColumnWidthException ()
300 listBox.ColumnWidth = -1;
304 [ExpectedException (typeof (InvalidEnumArgumentException))]
305 public void DrawModeException ()
307 listBox.DrawMode = (DrawMode) 10;
311 [ExpectedException (typeof (ArgumentException))]
312 public void DrawModeAndMultiColumnException ()
314 listBox.MultiColumn = true;
315 listBox.DrawMode = DrawMode.OwnerDrawVariable;
319 [ExpectedException (typeof (ArgumentOutOfRangeException))]
320 public void ItemHeightException ()
322 listBox.ItemHeight = 256;
326 public void SelectedIndex_Created ()
328 Form form = new Form ();
329 ListBox listBox = new ListBox ();
330 listBox.Items.Add ("A");
331 listBox.Items.Add ("B");
332 form.Controls.Add (listBox);
335 Assert.AreEqual (-1, listBox.SelectedIndex, "#1");
336 listBox.SelectedIndex = 0;
337 Assert.AreEqual (0, listBox.SelectedIndex, "#2");
338 listBox.SelectedIndex = -1;
339 Assert.AreEqual (-1, listBox.SelectedIndex, "#3");
340 listBox.SelectedIndex = 1;
341 Assert.AreEqual (1, listBox.SelectedIndex, "#4");
347 public void SelectedIndex_NotCreated ()
349 ListBox listBox = new ListBox ();
350 listBox.Items.Add ("A");
351 listBox.Items.Add ("B");
352 Assert.AreEqual (-1, listBox.SelectedIndex, "#1");
353 listBox.SelectedIndex = 0;
354 Assert.AreEqual (0, listBox.SelectedIndex, "#2");
355 listBox.SelectedIndex = -1;
356 Assert.AreEqual (-1, listBox.SelectedIndex, "#3");
357 listBox.SelectedIndex = 1;
358 Assert.AreEqual (1, listBox.SelectedIndex, "#4");
363 public void SelectedIndex_Removed ()
365 ListBox listBox = new ListBox ();
366 listBox.Items.Add ("A");
367 listBox.Items.Add ("B");
368 listBox.Items.Add ("C");
370 Assert.AreEqual (-1, listBox.SelectedIndex, "#1");
371 listBox.SelectedIndex = 2;
372 Assert.AreEqual (2, listBox.SelectedIndex, "#2");
373 listBox.Items.RemoveAt (2);
374 Assert.AreEqual (-1, listBox.SelectedIndex, "#3");
376 listBox.SelectedIndex = 0;
377 Assert.AreEqual (0, listBox.SelectedIndex, "#4");
378 listBox.Items.RemoveAt (0);
379 Assert.AreEqual (-1, listBox.SelectedIndex, "#5");
382 // This should also apply to MultiSimple selection mode
384 public void Selection_MultiExtended ()
386 listBox.Items.Add ("A");
387 listBox.Items.Add ("B");
388 listBox.Items.Add ("C");
389 listBox.Items.Add ("D");
390 listBox.SelectionMode = SelectionMode.MultiExtended;
393 // First part: test the order of SelectedItems as well
394 // as SelectedIndex when more than one item is selected
396 listBox.SelectedItems.Add ("D");
397 listBox.SelectedItems.Add ("B");
398 Assert.AreEqual (1, listBox.SelectedIndex, "#A1");
399 Assert.AreEqual (2, listBox.SelectedItems.Count, "#A2");
400 Assert.AreEqual ("B", listBox.SelectedItems [0], "#A3");
401 Assert.AreEqual ("D", listBox.SelectedItems [1], "#A4");
403 listBox.SelectedItems.Add ("C");
404 Assert.AreEqual (1, listBox.SelectedIndex, "#B1");
405 Assert.AreEqual (3, listBox.SelectedItems.Count, "#B2");
406 Assert.AreEqual ("B", listBox.SelectedItems [0], "#B3");
407 Assert.AreEqual ("C", listBox.SelectedItems [1], "#B4");
408 Assert.AreEqual ("D", listBox.SelectedItems [2], "#B5");
410 listBox.SelectedItems.Add ("A");
411 Assert.AreEqual (0, listBox.SelectedIndex, "#C1");
412 Assert.AreEqual (4, listBox.SelectedItems.Count, "#C2");
413 Assert.AreEqual ("A", listBox.SelectedItems [0], "#C3");
414 Assert.AreEqual ("B", listBox.SelectedItems [1], "#C4");
415 Assert.AreEqual ("C", listBox.SelectedItems [2], "#C5");
416 Assert.AreEqual ("D", listBox.SelectedItems [3], "#C6");
419 // Second part: how does SelectedIndex setter work related
422 listBox.SelectedIndex = -1;
423 Assert.AreEqual (-1, listBox.SelectedIndex, "#D1");
424 Assert.AreEqual (0, listBox.SelectedItems.Count, "#D2");
426 listBox.SelectedIndex = 3; // "D"
427 Assert.AreEqual (3, listBox.SelectedIndex, "#E1");
428 Assert.AreEqual (1, listBox.SelectedItems.Count, "#E2");
429 Assert.AreEqual ("D", listBox.SelectedItems [0], "#E3");
431 listBox.SelectedItems.Add ("B"); // index = 1
432 Assert.AreEqual (1, listBox.SelectedIndex, "#F1");
433 Assert.AreEqual (2, listBox.SelectedItems.Count, "#E3");
434 Assert.AreEqual ("B", listBox.SelectedItems [0], "#E4");
435 Assert.AreEqual ("D", listBox.SelectedItems [1], "#E5");
437 listBox.SelectedIndex = 2;
438 Assert.AreEqual (1, listBox.SelectedIndex, "#G1");
439 Assert.AreEqual (3, listBox.SelectedItems.Count, "#G2");
440 Assert.AreEqual ("B", listBox.SelectedItems [0], "#G3");
441 Assert.AreEqual ("C", listBox.SelectedItems [1], "#G4");
442 Assert.AreEqual ("D", listBox.SelectedItems [2], "#G5");
444 listBox.SelectedIndex = 1; // already selected
445 Assert.AreEqual (1, listBox.SelectedIndex, "#H1");
446 Assert.AreEqual (3, listBox.SelectedItems.Count, "#H2");
448 // NOTE: It seems that passing -1 does not affect the collection
449 // in anyway (other wrong values generate an exception, however)
450 listBox.SelectedIndices.Add (-1);
451 Assert.AreEqual (3, listBox.SelectedItems.Count, "#J1");
455 public void Selection_One ()
457 listBox.Items.Add ("A");
458 listBox.Items.Add ("B");
459 listBox.Items.Add ("C");
460 listBox.SelectionMode = SelectionMode.One;
462 listBox.SelectedItems.Add ("B");
463 Assert.AreEqual (1, listBox.SelectedIndex, "#A1");
464 Assert.AreEqual (1, listBox.SelectedItems.Count, "#A2");
465 Assert.AreEqual ("B", listBox.SelectedItems [0], "#A3");
467 listBox.SelectedIndex = 2;
468 Assert.AreEqual (2, listBox.SelectedIndex, "#B1");
469 Assert.AreEqual (1, listBox.SelectedItems.Count, "#B2");
470 Assert.AreEqual ("C", listBox.SelectedItems [0], "#B3");
472 listBox.SelectedItems.Add ("A");
473 Assert.AreEqual (0, listBox.SelectedIndex, "#C1");
474 Assert.AreEqual (1, listBox.SelectedItems.Count, "#C2");
475 Assert.AreEqual ("A", listBox.SelectedItems [0], "#C3");
479 public void Selection_None ()
481 listBox.Items.Add ("A");
482 listBox.Items.Add ("B");
483 listBox.SelectionMode = SelectionMode.None;
486 listBox.SelectedIndex = 0;
488 } catch (ArgumentException) {
492 listBox.SelectedIndices.Add (0);
494 } catch (InvalidOperationException e) {
495 Console.WriteLine (e.Message);
499 listBox.SelectedItems.Add ("A");
501 } catch (ArgumentException) {
507 [ExpectedException (typeof (ArgumentOutOfRangeException))]
508 public void SelectedIndexException ()
510 listBox.SelectedIndex = -2;
514 [ExpectedException (typeof (ArgumentOutOfRangeException))]
515 public void SelectedIndexException2 ()
517 listBox.SelectedIndex = listBox.Items.Count;
521 [ExpectedException (typeof (ArgumentException))]
522 public void SelectedIndexModeNoneException ()
524 listBox.SelectionMode = SelectionMode.None;
525 listBox.SelectedIndex = -1;
529 [ExpectedException (typeof (InvalidEnumArgumentException))]
530 public void SelectionModeException ()
532 listBox.SelectionMode = (SelectionMode) 10;
536 public void SelectedValueNull()
538 listBox.Items.Clear ();
540 listBox.Items.Add ("A");
541 listBox.Items.Add ("B");
542 listBox.Items.Add ("C");
543 listBox.Items.Add ("D");
545 listBox.SelectedIndex = 2;
546 listBox.SelectedValue = null;
547 Assert.AreEqual (listBox.SelectedIndex, 2);
551 public void SelectedValueEmptyString()
553 listBox.Items.Clear ();
555 listBox.Items.Add ("A");
556 listBox.Items.Add ("B");
557 listBox.Items.Add ("C");
558 listBox.Items.Add ("D");
560 listBox.SelectedIndex = 2;
561 listBox.SelectedValue = null;
562 Assert.AreEqual (listBox.SelectedIndex, 2);
566 public void SetItemsCore ()
568 MockListBox l = new MockListBox ();
569 l.InvokeSetItemsCore (new object [] { "A", "B", "C" });
570 Assert.AreEqual (3, l.Items.Count, "#1");
571 Assert.AreEqual ("A", l.Items [0], "#2");
572 Assert.AreEqual ("B", l.Items [1], "#3");
573 Assert.AreEqual ("C", l.Items [2], "#4");
577 public void SetItemsCore_Item_Null ()
579 MockListBox l = new MockListBox ();
581 l.InvokeSetItemsCore (new object [] { "A", null, "B" });
583 } catch (ArgumentNullException ex) {
584 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
585 Assert.IsNull (ex.InnerException, "#3");
586 Assert.IsNotNull (ex.Message, "#4");
587 Assert.AreEqual ("item", ex.ParamName, "#5");
591 Assert.AreEqual (1, l.Items.Count, "#6");
592 Assert.AreEqual ("A", l.Items [0], "#7");
594 Assert.AreEqual (0, l.Items.Count, "#6");
599 public void SetItemsCore_Value_Null ()
601 MockListBox l = new MockListBox ();
603 l.InvokeSetItemsCore ((IList) null);
605 } catch (ArgumentNullException ex) {
606 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
607 Assert.IsNull (ex.InnerException, "#3");
608 Assert.IsNotNull (ex.Message, "#4");
609 Assert.AreEqual ("items", ex.ParamName, "#5");
614 public void ListBoxHeight ()
616 ListBox l = new ListBox ();
618 for (int h = 0; h < 100; h++) {
622 Assert.Fail ("Set ListBox height of {0}, got back {1}. Should be the same.", h, l.Height);
628 public void GetScaledBoundsTest ()
630 ScaleListBox c = new ScaleListBox ();
632 Rectangle r = new Rectangle (100, 200, 300, 400);
634 Assert.AreEqual (new Rectangle (200, 100, 596, 50), c.PublicGetScaledBounds (r, new SizeF (2f, .5f), BoundsSpecified.All), "A1");
635 Assert.AreEqual (new Rectangle (200, 100, 300, 96), c.PublicGetScaledBounds (r, new SizeF (2f, .5f), BoundsSpecified.Location), "A2");
636 Assert.AreEqual (new Rectangle (100, 200, 596, 50), c.PublicGetScaledBounds (r, new SizeF (2f, .5f), BoundsSpecified.Size), "A3");
637 Assert.AreEqual (new Rectangle (100, 200, 300, 50), c.PublicGetScaledBounds (r, new SizeF (2f, .5f), BoundsSpecified.Height), "A4");
638 Assert.AreEqual (new Rectangle (200, 200, 300, 96), c.PublicGetScaledBounds (r, new SizeF (2f, .5f), BoundsSpecified.X), "A5");
639 Assert.AreEqual (new Rectangle (100, 200, 300, 96), c.PublicGetScaledBounds (r, new SizeF (2f, .5f), BoundsSpecified.None), "A6");
641 Assert.AreEqual (new Rectangle (100, 200, 300, 96), c.PublicGetScaledBounds (r, new SizeF (1f, 1f), BoundsSpecified.All), "A6-2");
642 Assert.AreEqual (new Rectangle (200, 400, 596, 188), c.PublicGetScaledBounds (r, new SizeF (2f, 2f), BoundsSpecified.All), "A7");
643 Assert.AreEqual (new Rectangle (300, 600, 892, 280), c.PublicGetScaledBounds (r, new SizeF (3f, 3f), BoundsSpecified.All), "A8");
644 Assert.AreEqual (new Rectangle (400, 800, 1188, 372), c.PublicGetScaledBounds (r, new SizeF (4f, 4f), BoundsSpecified.All), "A9");
645 Assert.AreEqual (new Rectangle (50, 100, 152, 50), c.PublicGetScaledBounds (r, new SizeF (.5f, .5f), BoundsSpecified.All), "A10");
649 [NUnit.Framework.Category ("NotWorking")]
650 public void MethodScaleControl ()
652 Form f = new Form ();
653 f.ShowInTaskbar = false;
657 ScaleListBox gb = new ScaleListBox ();
658 gb.Location = new Point (5, 10);
661 Assert.AreEqual (new Rectangle (5, 10, 120, 95), gb.Bounds, "A1");
663 gb.PublicScaleControl (new SizeF (2.0f, 2.0f), BoundsSpecified.All);
664 Assert.AreEqual (new Rectangle (10, 20, 236, 186), gb.Bounds, "A2");
666 gb.PublicScaleControl (new SizeF (.5f, .5f), BoundsSpecified.Location);
667 Assert.AreEqual (new Rectangle (5, 10, 236, 186), gb.Bounds, "A3");
669 gb.PublicScaleControl (new SizeF (.5f, .5f), BoundsSpecified.Size);
670 Assert.AreEqual (new Rectangle (5, 10, 120, 95), gb.Bounds, "A4");
672 gb.PublicScaleControl (new SizeF (3.5f, 3.5f), BoundsSpecified.Size);
673 Assert.AreEqual (new Rectangle (5, 10, 410, 316), gb.Bounds, "A5");
675 gb.PublicScaleControl (new SizeF (2.5f, 2.5f), BoundsSpecified.Size);
676 Assert.AreEqual (new Rectangle (5, 10, 1019, 797), gb.Bounds, "A6");
678 gb.PublicScaleControl (new SizeF (.2f, .2f), BoundsSpecified.Size);
679 Assert.AreEqual (new Rectangle (5, 10, 207, 160), gb.Bounds, "A7");
684 private class ScaleListBox : ListBox
686 public Rectangle PublicGetScaledBounds (Rectangle bounds, SizeF factor, BoundsSpecified specified)
688 return base.GetScaledBounds (bounds, factor, specified);
691 public void PublicScaleControl (SizeF factor, BoundsSpecified specified)
693 base.ScaleControl (factor, specified);
699 public void MethodIsInputChar ()
701 // Basically, show that this method always returns true
702 InputCharControl m = new InputCharControl ();
705 for (int i = 0; i < 256; i++)
706 result &= m.PublicIsInputChar ((char)i);
708 Assert.AreEqual (true, result, "I1");
711 private class InputCharControl : ListBox
713 public bool PublicIsInputChar (char charCode)
715 return base.IsInputChar (charCode);
720 public void HeightAndIntegralHeight ()
722 ListBox a = new ListBox();
723 Size defaultSize = new Size(120, 96);
724 Assert.AreEqual (defaultSize, a.Size, "A1");
726 Assert.AreEqual (0, (a.ClientSize.Height % a.ItemHeight), "A2");
727 a.IntegralHeight = false;
728 Assert.AreEqual (a.Size, defaultSize, "A3");
729 a.IntegralHeight = true;
730 Assert.AreEqual (0, (a.ClientSize.Height % a.ItemHeight), "A4");
732 Size clientSizeI = new Size(200, a.ItemHeight * 5);
733 Size clientSize = clientSizeI + new Size(0, a.ItemHeight / 2);
734 Size borderSize = new Size(a.Width - a.ClientSize.Width, a.Height - a.ClientSize.Height);
735 Size totalSizeI = clientSizeI + borderSize;
736 Size totalSize = clientSize + borderSize;
739 a.ClientSize = clientSize;
740 Assert.AreEqual (clientSize, a.ClientSize, "A5");
741 Assert.AreEqual (totalSize, a.Size, "A6");
742 a.IntegralHeight = false;
743 a.IntegralHeight = true;
744 Assert.AreEqual (clientSize, a.ClientSize, "A7");
746 Assert.AreEqual (clientSizeI, a.ClientSize, "A8");
747 Assert.AreEqual (totalSizeI, a.Size, "A9");
748 a.IntegralHeight = false;
749 Assert.AreEqual (clientSize, a.ClientSize, "A10");
750 a.IntegralHeight = true;
751 Assert.AreEqual (totalSizeI, a.Size, "A11");
756 Assert.AreEqual (totalSizeI, a.Size, "A12");
757 Assert.AreEqual (clientSizeI, a.ClientSize, "A13");
758 a.IntegralHeight = false;
759 Assert.AreEqual (totalSize, a.Size, "A14");
760 Assert.AreEqual (clientSize, a.ClientSize, "A15");
763 a.IntegralHeight = false;
764 Assert.AreEqual (defaultSize, a.Size, "A16");
766 Assert.AreEqual (defaultSize, a.Size, "A17");
769 a.ClientSize = clientSize;
770 a.IntegralHeight = false;
771 Assert.AreEqual (clientSize, a.ClientSize, "A18");
773 Assert.AreEqual (clientSize, a.ClientSize, "A19");
777 public void PropertyTopIndex ()
779 Form f = new Form ();
780 f.ShowInTaskbar = false;
783 ListBox l = new ListBox ();
787 l.Items.AddRange (new string[] { "A", "B", "C"});
789 Assert.AreEqual (0, l.TopIndex, "A1");
792 Assert.AreEqual (0, l.TopIndex, "A2");
794 l.Items.AddRange (new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M" });
795 Assert.AreEqual (0, l.TopIndex, "A3");
798 Assert.AreEqual (2, l.TopIndex, "A4");
800 // There aren't items enough for 12 to be the top index, but
801 // the actual value is font height dependent.
803 Assert.IsTrue (l.TopIndex < 12, "A5");
812 //private bool eventFired;
814 //private void GenericHandler (object sender, EventArgs e)
816 // eventFired = true;
819 public class MockListBox : ListBox
822 public bool allow_selection {
823 get { return base.AllowSelection; }
827 public void InvokeSetItemsCore (IList value)
829 base.SetItemsCore (value);
834 public void AddToSorted ()
836 AddItems (true, CheckedListBoxTest.Items, CheckedListBoxTest.ExpectedAddPositionsSorted);
840 public void AddToUnsorted ()
842 AddItems (false, CheckedListBoxTest.Items, CheckedListBoxTest.ExpectedAddPositionsUnsorted);
845 void AddItems (bool sorted, object[] items, int[] expectedAddPositions)
847 ListBox clb = new ListBox ();
849 ArrayList addedAtList = new ArrayList ();
850 foreach (object cur in items)
852 int idx = clb.Items.Add (cur);
853 addedAtList.Add (idx);
855 Assert.AreEqual ((Array)expectedAddPositions, (Array)addedAtList.ToArray (typeof (int)), "addedAtList");
860 public class ListBoxObjectCollectionTest : TestHelper
862 ListBox.ObjectCollection col;
865 protected override void SetUp ()
867 col = new ListBox.ObjectCollection (new ListBox ());
871 public void DefaultProperties ()
873 Assert.AreEqual (false, col.IsReadOnly, "#B1");
874 Assert.AreEqual (false, ((ICollection)col).IsSynchronized, "#B2");
875 Assert.AreEqual (col, ((ICollection)col).SyncRoot, "#B3");
876 Assert.AreEqual (false, ((IList)col).IsFixedSize, "#B4");
877 Assert.AreEqual (0, col.Count);
885 Assert.AreEqual (2, col.Count, "#1");
886 Assert.AreEqual ("Item1", col [0], "#2");
887 Assert.AreEqual ("Item2", col [1], "#3");
891 public void Add_Item_Null ()
896 } catch (ArgumentNullException ex) {
897 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
898 Assert.IsNull (ex.InnerException, "#3");
899 Assert.IsNotNull (ex.Message, "#4");
900 Assert.AreEqual ("item", ex.ParamName, "#5");
904 [Test] // AddRange (Object [])
905 public void AddRange1_Items_Null ()
908 col.AddRange ((object []) null);
910 } catch (ArgumentNullException ex) {
911 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
912 Assert.IsNull (ex.InnerException, "#3");
913 Assert.IsNotNull (ex.Message, "#4");
914 Assert.AreEqual ("items", ex.ParamName, "#5");
918 [Test] // AddRange (ListBox.ObjectCollection)
919 public void AddRange2_Value_Null ()
922 col.AddRange ((ListBox.ObjectCollection) null);
924 } catch (ArgumentNullException ex) {
925 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
926 Assert.IsNull (ex.InnerException, "#3");
927 Assert.IsNotNull (ex.Message, "#4");
928 Assert.AreEqual ("items", ex.ParamName, "#5");
938 Assert.AreEqual (0, col.Count, "#D1");
942 public void Contains ()
944 object obj = "Item1";
946 Assert.IsTrue (col.Contains ("Item1"), "#1");
947 Assert.IsFalse (col.Contains ("Item2"), "#2");
951 public void Contains_Value_Null ()
956 } catch (ArgumentNullException ex) {
957 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
958 Assert.IsNull (ex.InnerException, "#3");
959 Assert.IsNotNull (ex.Message, "#4");
961 Assert.AreEqual ("value", ex.ParamName, "#5");
963 Assert.IsNotNull (ex.ParamName, "#5");
969 public void Indexer_Value_Null ()
975 } catch (ArgumentNullException ex) {
976 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
977 Assert.IsNull (ex.InnerException, "#3");
978 Assert.IsNotNull (ex.Message, "#4");
979 Assert.AreEqual ("value", ex.ParamName, "#5");
984 public void IndexOf ()
988 Assert.AreEqual (1, col.IndexOf ("Item2"), "#1");
989 Assert.AreEqual (0, col.IndexOf ("Item1"), "#2");
990 Assert.AreEqual (-1, col.IndexOf ("Item3"), "#3");
994 public void IndexOf_Value_Null ()
999 } catch (ArgumentNullException ex) {
1000 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1001 Assert.IsNull (ex.InnerException, "#3");
1002 Assert.IsNotNull (ex.Message, "#4");
1004 Assert.AreEqual ("value", ex.ParamName, "#5");
1006 Assert.IsNotNull (ex.ParamName, "#5");
1013 [NUnit.Framework.Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=363285
1015 public void Insert_Item_Null ()
1019 col.Insert (0, null);
1021 } catch (ArgumentNullException ex) {
1022 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1023 Assert.IsNull (ex.InnerException, "#3");
1024 Assert.IsNotNull (ex.Message, "#4");
1025 Assert.AreEqual ("item", ex.ParamName, "#5");
1030 public void Remove ()
1034 col.Remove ("Item1");
1035 Assert.AreEqual (1, col.Count, "#A1");
1036 Assert.AreEqual (-1, col.IndexOf ("Item1"), "#A2");
1037 Assert.AreEqual (0, col.IndexOf ("Item2"), "#A3");
1039 Assert.AreEqual (1, col.Count, "#B1");
1040 Assert.AreEqual (-1, col.IndexOf ("Item1"), "#B2");
1041 Assert.AreEqual (0, col.IndexOf ("Item2"), "#B3");
1042 col.Remove ("Item3");
1043 Assert.AreEqual (1, col.Count, "#C1");
1044 Assert.AreEqual (-1, col.IndexOf ("Item1"), "#C2");
1045 Assert.AreEqual (0, col.IndexOf ("Item2"), "#C3");
1046 col.Remove ("Item2");
1047 Assert.AreEqual (0, col.Count, "#D1");
1048 Assert.AreEqual (-1, col.IndexOf ("Item1"), "#D2");
1049 Assert.AreEqual (-1, col.IndexOf ("Item2"), "#D3");
1053 public void RemoveAt ()
1058 Assert.AreEqual (1, col.Count, "#1");
1059 Assert.AreEqual (-1, col.IndexOf ("Item1"), "#2");
1060 Assert.AreEqual (0, col.IndexOf ("Item2"), "#3");
1066 public class ListBoxIntegerCollectionTest : TestHelper
1068 ListBox.IntegerCollection col;
1072 protected override void SetUp ()
1074 listBox = new ListBox ();
1075 col = new ListBox.IntegerCollection (listBox);
1082 Assert.AreEqual (1, col.Count, "#1");
1084 Assert.AreEqual (2, col.Count, "#2");
1086 Assert.AreEqual (2, col.Count, "#3");
1088 Assert.AreEqual (3, col.Count, "#4");
1091 [Test] // AddRange (Int32 [])
1092 public void AddRange1 ()
1096 col.AddRange (new int [] { 3, 7, 9, 5, 4 });
1097 Assert.AreEqual (5, col.Count, "#1");
1098 Assert.AreEqual (3, col [0], "#2");
1099 Assert.AreEqual (4, col [1], "#3");
1100 Assert.AreEqual (5, col [2], "#4");
1101 Assert.AreEqual (7, col [3], "#5");
1102 Assert.AreEqual (9, col [4], "#6");
1105 [Test] // AddRange (Int32 [])
1106 public void AddRange1_Items_Null ()
1109 col.AddRange ((int []) null);
1111 } catch (ArgumentNullException ex) {
1112 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1113 Assert.IsNull (ex.InnerException, "#3");
1114 Assert.IsNotNull (ex.Message, "#4");
1115 Assert.AreEqual ("items", ex.ParamName, "#5");
1119 [Test] // AddRange (ListBox.IntegerCollection)
1120 public void AddRange2 ()
1122 ListBox.IntegerCollection ints = new ListBox.IntegerCollection (
1133 col.AddRange (ints);
1135 Assert.AreEqual (7, col.Count, "#1");
1136 Assert.AreEqual (-5, col [0], "#2");
1137 Assert.AreEqual (1, col [1], "#3");
1138 Assert.AreEqual (2, col [2], "#4");
1139 Assert.AreEqual (3, col [3], "#5");
1140 Assert.AreEqual (4, col [4], "#6");
1141 Assert.AreEqual (5, col [5], "#7");
1144 [Test] // AddRange (ListBox.IntegerCollection)
1145 public void AddRange2_Items_Null ()
1148 col.AddRange ((ListBox.IntegerCollection) null);
1150 } catch (ArgumentNullException ex) {
1151 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1152 Assert.IsNull (ex.InnerException, "#3");
1153 Assert.IsNotNull (ex.Message, "#4");
1154 Assert.AreEqual ("items", ex.ParamName, "#5");
1159 [NUnit.Framework.Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=363278
1160 public void Clear ()
1166 Assert.AreEqual (0, col.Count, "#1");
1167 Assert.AreEqual (-1, col.IndexOf (5), "#2");
1168 Assert.AreEqual (-1, col.IndexOf (3), "#3");
1172 public void Contains ()
1176 Assert.IsTrue (col.Contains (5), "#1");
1177 Assert.IsFalse (col.Contains (3), "#2");
1178 Assert.IsTrue (col.Contains (7), "#3");
1179 Assert.IsFalse (col.Contains (-5), "#4");
1183 public void CopyTo ()
1185 int [] copy = new int [5] { 9, 4, 6, 2, 8 };
1190 col.CopyTo (copy, 1);
1192 Assert.AreEqual (9, copy [0], "#1");
1193 Assert.AreEqual (3, copy [1], "#2");
1194 Assert.AreEqual (5, copy [2], "#3");
1195 Assert.AreEqual (7, copy [3], "#4");
1196 Assert.AreEqual (8, copy [4], "#5");
1200 public void CopyTo_Destination_Invalid ()
1202 string [] copy = new string [3] { "A", "B", "C" };
1204 col.CopyTo (copy, 1);
1208 col.CopyTo (copy, 1);
1210 } catch (InvalidCastException) {
1215 public void CopyTo_Destination_Null ()
1217 col.CopyTo ((Array) null, 1);
1221 col.CopyTo ((Array) null, 1);
1223 } catch (NullReferenceException) {
1228 public void CopyTo_Index_Negative ()
1230 int [] copy = new int [5] { 9, 4, 6, 2, 8 };
1232 col.CopyTo (copy, -5);
1236 col.CopyTo (copy, -5);
1238 } catch (IndexOutOfRangeException ex) {
1239 // Index was outside the bounds of the array
1240 Assert.AreEqual (typeof (IndexOutOfRangeException), ex.GetType (), "#2");
1241 Assert.IsNull (ex.InnerException, "#3");
1242 Assert.IsNotNull (ex.Message, "#4");
1247 public void Count ()
1249 Assert.AreEqual (0, col.Count, "#1");
1251 Assert.AreEqual (1, col.Count, "#2");
1253 Assert.AreEqual (2, col.Count, "#3");
1255 Assert.AreEqual (1, col.Count, "#4");
1259 public void Indexer ()
1263 Assert.AreEqual (7, col [1], "#1");
1264 Assert.AreEqual (5, col [0], "#2");
1266 Assert.AreEqual (7, col [1], "#3");
1267 Assert.AreEqual (3, col [0], "#4");
1271 public void IndexOf ()
1275 Assert.AreEqual (0, col.IndexOf (5), "#1");
1276 Assert.AreEqual (-1, col.IndexOf (3), "#2");
1277 Assert.AreEqual (1, col.IndexOf (7), "#3");
1278 Assert.AreEqual (-1, col.IndexOf (-5), "#4");
1282 public void Remove ()
1289 Assert.AreEqual (1, col.Count, "#1");
1290 Assert.AreEqual (3, col [0], "#2");
1292 Assert.AreEqual (0, col.Count, "#3");
1294 // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=363280
1295 //Assert.AreEqual (0, col.Count, "#4");
1299 public void RemoveAt ()
1305 Assert.AreEqual (2, col.Count, "#A1");
1306 Assert.AreEqual (3, col [0], "#A2");
1307 Assert.AreEqual (7, col [1], "#A3");
1309 Assert.AreEqual (1, col.Count, "#B1");
1310 Assert.AreEqual (7, col [0], "#B2");
1312 Assert.AreEqual (0, col.Count, "#C1");
1313 Assert.AreEqual (-1, col.IndexOf (5), "#C2");
1314 Assert.AreEqual (-1, col.IndexOf (3), "#C3");
1315 // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=363280
1316 //Assert.AreEqual (-1, col.IndexOf (7), "#C4");
1320 [NUnit.Framework.Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=363276
1321 public void RemoveAt_Index_Negative ()
1328 } catch (IndexOutOfRangeException ex) {
1329 // Index was outside the bounds of the array
1330 Assert.AreEqual (typeof (IndexOutOfRangeException), ex.GetType (), "#2");
1331 Assert.IsNull (ex.InnerException, "#3");
1332 Assert.IsNotNull (ex.Message, "#4");
1335 Assert.AreEqual (1, col.Count, "#5");
1339 [NUnit.Framework.Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=363276
1340 public void RemoveAt_Index_Overflow ()
1347 } catch (ArgumentOutOfRangeException ex) {
1348 // Index was outside the bounds of the array
1349 Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
1350 Assert.IsNull (ex.InnerException, "#3");
1351 Assert.IsNotNull (ex.Message, "#4");
1352 Assert.AreEqual ("index", ex.ParamName, "#5");
1355 Assert.AreEqual (1, col.Count, "#6");
1359 public void ICollection_IsSynchronized ()
1361 ICollection collection = (ICollection) col;
1362 Assert.IsTrue (collection.IsSynchronized);
1366 public void ICollection_SyncRoot ()
1368 ICollection collection = (ICollection) col;
1369 Assert.AreSame (collection, collection.SyncRoot);
1373 public void IList_Add ()
1375 IList list = (IList) col;
1377 Assert.AreEqual (1, list.Count, "#1");
1379 Assert.AreEqual (2, list.Count, "#2");
1381 Assert.AreEqual (2, list.Count, "#3");
1383 Assert.AreEqual (3, list.Count, "#4");
1387 public void IList_Add_Item_Invalid ()
1389 IList list = (IList) col;
1393 Assert.Fail ("#A1");
1394 } catch (ArgumentException ex) {
1395 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1396 Assert.IsNull (ex.InnerException, "#A3");
1397 Assert.AreEqual ("item", ex.Message, "#A4");
1398 Assert.IsNull (ex.ParamName, "#A5");
1403 Assert.Fail ("#B1");
1404 } catch (ArgumentException ex) {
1405 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1406 Assert.IsNull (ex.InnerException, "#B3");
1407 Assert.AreEqual ("item", ex.Message, "#B4");
1408 Assert.IsNull (ex.ParamName, "#B5");
1413 public void IList_Clear ()
1415 IList list = (IList) col;
1419 Assert.AreEqual (0, list.Count);
1423 public void IList_Contains ()
1425 IList list = (IList) col;
1428 Assert.IsTrue (list.Contains (5), "#1");
1429 Assert.IsFalse (list.Contains (3), "#2");
1430 Assert.IsTrue (list.Contains (7), "#3");
1431 Assert.IsFalse (list.Contains (null), "#4");
1432 Assert.IsFalse (list.Contains ("x"), "#5");
1436 public void IList_Indexer ()
1438 IList list = (IList) col;
1441 Assert.AreEqual (7, list [1], "#1");
1442 Assert.AreEqual (5, list [0], "#2");
1444 Assert.AreEqual (7, list [1], "#3");
1445 Assert.AreEqual (3, list [0], "#4");
1449 public void IList_IndexOf ()
1451 IList list = (IList) col;
1454 Assert.AreEqual (0, list.IndexOf (5), "#1");
1455 Assert.AreEqual (-1, list.IndexOf (3), "#2");
1456 Assert.AreEqual (1, list.IndexOf (7), "#3");
1457 Assert.AreEqual (-1, list.IndexOf (null), "#4");
1458 Assert.AreEqual (-1, list.IndexOf ("x"), "#5");
1462 public void IList_Insert ()
1464 IList list = (IList) col;
1469 Assert.Fail ("#A1");
1470 } catch (NotSupportedException ex) {
1471 // ListBox.IntegerCollection is sorted, and
1472 // items cannot be inserted into it
1473 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#A2");
1474 Assert.IsNull (ex.InnerException, "#A3");
1475 Assert.IsNotNull (ex.Message, "#A4");
1479 list.Insert (-5, null);
1480 Assert.Fail ("#B1");
1481 } catch (NotSupportedException ex) {
1482 // ListBox.IntegerCollection is sorted, and
1483 // items cannot be inserted into it
1484 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#B2");
1485 Assert.IsNull (ex.InnerException, "#B3");
1486 Assert.IsNotNull (ex.Message, "#B4");
1491 public void IList_IsFixedSize ()
1493 IList list = (IList) col;
1494 Assert.IsFalse (list.IsFixedSize);
1498 public void IList_IsReadOnly ()
1500 IList list = (IList) col;
1501 Assert.IsFalse (list.IsReadOnly);
1505 public void IList_Remove ()
1507 IList list = (IList) col;
1512 list.Remove (int.MinValue);
1513 list.Remove (int.MaxValue);
1515 Assert.AreEqual (1, list.Count, "#1");
1516 Assert.AreEqual (3, list [0], "#2");
1518 Assert.AreEqual (0, list.Count, "#3");
1522 public void IList_Remove_Value_Invalid ()
1524 IList list = (IList) col;
1529 Assert.Fail ("#A1");
1530 } catch (ArgumentException ex) {
1531 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1532 Assert.IsNull (ex.InnerException, "#A3");
1533 Assert.AreEqual ("value", ex.Message, "#A4");
1534 Assert.IsNull (ex.ParamName, "#A5");
1539 Assert.Fail ("#B1");
1540 } catch (ArgumentException ex) {
1541 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1542 Assert.IsNull (ex.InnerException, "#B3");
1543 Assert.AreEqual ("value", ex.Message, "#B4");
1544 Assert.IsNull (ex.ParamName, "#B5");
1549 public void IList_RemoveAt ()
1551 IList list = (IList) col;
1556 Assert.AreEqual (2, list.Count, "#A1");
1557 Assert.AreEqual (3, list [0], "#A2");
1558 Assert.AreEqual (7, list [1], "#A3");
1560 Assert.AreEqual (1, list.Count, "#B1");
1561 Assert.AreEqual (7, list [0], "#B2");
1563 Assert.AreEqual (0, list.Count, "#C");
1567 public void IList_RemoveAt_Index_Negative ()
1569 IList list = (IList) col;
1575 } catch (IndexOutOfRangeException ex) {
1576 // Index was outside the bounds of the array
1577 Assert.AreEqual (typeof (IndexOutOfRangeException), ex.GetType (), "#2");
1578 Assert.IsNull (ex.InnerException, "#3");
1579 Assert.IsNotNull (ex.Message, "#4");
1582 // // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=363276
1583 //Assert.AreEqual (1, list.Count, "#5");
1587 [NUnit.Framework.Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=363276
1588 public void IList_RemoveAt_Index_Overflow ()
1590 IList list = (IList) col;
1596 } catch (ArgumentOutOfRangeException ex) {
1597 // Index was outside the bounds of the array
1598 Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
1599 Assert.IsNull (ex.InnerException, "#3");
1600 Assert.IsNotNull (ex.Message, "#4");
1601 Assert.AreEqual ("index", ex.ParamName, "#5");
1604 Assert.AreEqual (1, list.Count, "#6");