Test for bug 16902
authorscottmcarthur <github@scottmcarthur.co.uk>
Sun, 22 Dec 2013 18:08:16 +0000 (18:08 +0000)
committerscottmcarthur <github@scottmcarthur.co.uk>
Sun, 22 Dec 2013 18:08:16 +0000 (18:08 +0000)
Check insert of null item, in a BindingList<T> where T implements INotifyPropertyChanged does not cause NullReferenceException.

mcs/class/System/Test/System.ComponentModel/BindingListTest.cs

index 88be568f429b51540cf9967c8e84e15cc1864c36..92a6253db915b6bc3d0d3643689b8ae02f134512 100644 (file)
@@ -629,6 +629,16 @@ namespace MonoTests.System.ComponentModel
                        Assert.IsTrue (added, "ItemAdded");
                        Assert.IsTrue (changed, "ItemChanged");
                }
+               
+               [Test] // https://bugzilla.xamarin.com/show_bug.cgi?id=16902
+               public void Bug16902 ()
+               {
+                       var list = new BindingList<Item> ();
+                       list.Insert (0, null);
+                       var count = list.Count;
+                       
+                       Assert.AreEqual (1, count, "1");
+               }
        }
 }