Exemple #1
0
        public void RemoveAtIBindingList()
        {
            ViewFactory factory = ViewFactory.IBindingListSimpleItems();

            factory.List.Add(new SimpleClass(100, "aaa", new DateTime(1970, 1, 1)));
            SimpleClass bbb = new SimpleClass(80, "bbb", new DateTime(1980, 12, 12));

            factory.List.Add(bbb);
            factory.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.ListChangedDeletedCount);
            Assert.AreEqual(1, factory.RemovingItemCount);
            Assert.AreEqual(0, removingIndex);
        }
Exemple #2
0
        public void EndNewWithoutAddNewWithListAdd()
        {
            var factory = ViewFactory.IBindingListSimpleItems();
            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 CancelNewWithoutAddNewWithListAdd()
        {
            ViewFactory    factory = ViewFactory.IBindingListSimpleItems();
            ObjectListView 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 ClearIBindingList()
        {
            var factory = ViewFactory.IBindingListSimpleItems();

            var item = factory.CreateItem();

            factory.List.Add(item);
            factory.ClearEventCounts();

            factory.View.Clear();
            Assert.AreEqual(1, factory.ListChangedResetCount);
            Assert.AreEqual(0, factory.List.Count);
        }
        public void ItemSetIBindingList()
        {
            var factory = ViewFactory.IBindingListSimpleItems();

            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[1] = new SimpleClass(200, "ddd", new DateTime(1963, 3, 9));

            Assert.AreEqual(1, factory.ListChangedItemChangedCount);

            var 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);
        }