public void RemoveAtIBindingList() { ViewFactory <SimpleClass> factory = ViewFactory <SimpleClass> .IBindingList(); IList <SimpleClass> list = factory.List; list.Add(new SimpleClass(100, "aaa", new DateTime(1970, 1, 1))); list.Add(new SimpleClass(80, "bbb", new DateTime(1980, 12, 12))); list.Add(new SimpleClass(60, "ccc", new DateTime(1975, 6, 6))); factory.ClearEventCounts(); int removingIndex = -1; factory.View.RemovingItem += delegate(object sender, RemovingItemEventArgs args) { removingIndex = args.Index; }; factory.View.RemoveAt(0); Assert.AreEqual(2, factory.List.Count); Assert.AreEqual("bbb", ((SimpleClass)factory.List[0]).StringValue); Assert.AreEqual(1, factory.RemovingItemCount); Assert.AreEqual(0, removingIndex); }
public void EndNewWithoutAddNewWithListAdd() { var factory = ViewFactory <SimpleClass> .IBindingList(); var view = factory.View; factory.List.Add(new SimpleClass()); Assert.AreEqual(1, factory.ListChangedAddedCount); ((ICancelAddNew)view).EndNew(0); Assert.AreEqual(1, factory.ListChangedAddedCount); }
public void ClearIBindingList() { ViewFactory <SimpleClass> factory = ViewFactory <SimpleClass> .IBindingList(); SimpleClass item = factory.CreateItem(); factory.List.Add(item); factory.ClearEventCounts(); ((IList)factory.View).Clear(); Assert.AreEqual(1, factory.ListChangedResetCount); Assert.AreEqual(0, factory.List.Count); }
public void CancelNewWithoutAddNewWithListAdd() { ViewFactory <SimpleClass> factory = ViewFactory <SimpleClass> .IBindingList(); ObjectListView <SimpleClass> view = factory.View; factory.List.Add(new SimpleClass()); Assert.AreEqual(1, factory.ListChangedAddedCount); ((ICancelAddNew)view).CancelNew(0); Assert.AreEqual(1, factory.ListChangedAddedCount); Assert.AreEqual(0, factory.ListChangedDeletedCount); }
public void InsertIBindingList() { ViewFactory <SimpleClass> factory = ViewFactory <SimpleClass> .IBindingList(); factory.List.Add(new SimpleClass(100, "aaa", new DateTime(1970, 1, 1))); factory.List.Add(new SimpleClass(80, "bbb", new DateTime(1980, 12, 12))); factory.List.Add(new SimpleClass(60, "ccc", new DateTime(1975, 6, 6))); factory.ClearEventCounts(); factory.View.Insert(1, new SimpleClass(200, "ddd", new DateTime(1963, 3, 9))); Assert.AreEqual(4, factory.View.Count); Assert.AreEqual(1, factory.ListChangedAddedCount); SimpleClass item = factory.List[1]; Assert.AreEqual(200, item.IntegerValue); Assert.AreEqual("ddd", item.StringValue); Assert.AreEqual(new DateTime(1963, 3, 9), item.DateTimeValue); }
public void ItemSetIBindingList() { ViewFactory <SimpleClass> factory = ViewFactory <SimpleClass> .IBindingList(); factory.List.Add(new SimpleClass(100, "aaa", new DateTime(1970, 1, 1))); factory.List.Add(new SimpleClass(80, "bbb", new DateTime(1980, 12, 12))); factory.List.Add(new SimpleClass(60, "ccc", new DateTime(1975, 6, 6))); factory.ClearEventCounts(); ((IList)factory.View)[1] = new SimpleClass(200, "ddd", new DateTime(1963, 3, 9)); Assert.AreEqual(1, factory.ListChangedItemChangedCount); object item = factory.List[1]; Assert.IsTrue(item is SimpleClass); Assert.AreEqual(200, ((SimpleClass)item).IntegerValue); Assert.AreEqual("ddd", ((SimpleClass)item).StringValue); Assert.AreEqual(new DateTime(1963, 3, 9), ((SimpleClass)item).DateTimeValue); }