Пример #1
0
        public void Add()
        {
            var factory = ViewFactory <SimpleClass> .IList();

            var list = factory.List;
            var view = factory.View;

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

            view.Add(new SimpleClass(200, "ddd", new DateTime(1963, 3, 9)));

            Assert.AreEqual(4, list.Count);
            Assert.AreEqual(1, factory.ListChangedAddedCount);
            Assert.AreEqual(0, factory.ListChangedItemChangedCount);

            var item = list[3];

            Assert.AreEqual(200, item.IntegerValue);
            Assert.AreEqual("ddd", item.StringValue);
            Assert.AreEqual(new DateTime(1963, 3, 9), item.DateTimeValue);
        }
Пример #2
0
        public void AddIBindingList()
        {
            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.Add(new SimpleClass(200, "ddd", new DateTime(1963, 3, 9)));

            Assert.AreEqual(4, factory.List.Count);
            Assert.AreEqual(1, factory.ListChangedAddedCount);
            Assert.AreEqual(0, factory.ListChangedItemChangedCount);

            object item = factory.List[3];

            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);
        }
Пример #3
0
        public void RemoveAt()
        {
            var factory = ViewFactory <SimpleClass> .IList();

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

            var removingIndex = -1;

            factory.View.RemovingItem += delegate(object sender, RemovingItemEventArgs args) { removingIndex = args.Index; };

            ((IList)factory.View).RemoveAt(0);

            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("bbb", list[0].StringValue);
            Assert.AreEqual(1, factory.RemovingItemCount);
            Assert.AreEqual(0, removingIndex);
        }
Пример #4
0
        public void GetEnumeratorNonEmptyList()
        {
            ViewFactory <SimpleClass> factory = ViewFactory <SimpleClass> .IList();

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

            IEnumerator <SimpleClass> e = factory.View.GetEnumerator();

            Assert.IsNotNull(e);

            Assert.IsTrue(e.MoveNext());
            SimpleClass item = e.Current;

            Assert.IsNotNull(item);
            Assert.AreEqual(100, item.IntegerValue);
            Assert.AreEqual("aaa", item.StringValue);
            Assert.AreEqual(new DateTime(1970, 1, 1), item.DateTimeValue);

            Assert.IsTrue(e.MoveNext());
            item = e.Current;
            Assert.IsNotNull(item);
            Assert.AreEqual(80, item.IntegerValue);
            Assert.AreEqual("bbb", item.StringValue);
            Assert.AreEqual(new DateTime(1980, 12, 12), item.DateTimeValue);

            Assert.IsTrue(e.MoveNext());
            item = e.Current;
            Assert.IsNotNull(item);
            Assert.AreEqual(60, item.IntegerValue);
            Assert.AreEqual("ccc", item.StringValue);
            Assert.AreEqual(new DateTime(1975, 6, 6), item.DateTimeValue);

            Assert.IsFalse(e.MoveNext());
        }
        public void RaisesItemChangedEvents()
        {
            ViewFactory <SimpleClass> factory = ViewFactory <SimpleClass> .IList();

            Assert.IsTrue(((IRaiseItemChangedEvents)factory.View).RaisesItemChangedEvents);
        }
        public void IsIRaiseItemChangedEvents()
        {
            ViewFactory <SimpleClass> factory = ViewFactory <SimpleClass> .IList();

            Assert.IsTrue(factory.View is IRaiseItemChangedEvents);
        }
Пример #7
0
        public void IsReadOnly()
        {
            ViewFactory <SimpleClass> factory = ViewFactory <SimpleClass> .IList();

            Assert.IsFalse(((IList)factory.View).IsReadOnly);
        }
Пример #8
0
        public void IsFixedSize()
        {
            ViewFactory <SimpleClass> factory = ViewFactory <SimpleClass> .IList();

            Assert.IsFalse(((IList)factory.View).IsFixedSize);
        }
Пример #9
0
        public void SyncRoot()
        {
            var factory = ViewFactory <SimpleClass> .IList();

            Assert.IsNull(((IList)factory.View).SyncRoot);
        }
Пример #10
0
        public void IsSynchronized()
        {
            var factory = ViewFactory <SimpleClass> .IList();

            Assert.IsFalse(((IList)factory.View).IsSynchronized);
        }
Пример #11
0
        public void CountEmptyList()
        {
            var factory = ViewFactory <SimpleClass> .IList();

            Assert.AreEqual(0, ((ICollection)factory.View).Count);
        }
Пример #12
0
        public void IsReadOnly()
        {
            var factory = ViewFactory <SimpleClass> .IList();

            Assert.AreEqual(factory.List.IsReadOnly, factory.View.IsReadOnly);
        }
Пример #13
0
        public void CountEmptyList()
        {
            var factory = ViewFactory <SimpleClass> .IList();

            Assert.AreEqual(0, factory.View.Count);
        }