public void Remove_By_Object_Calls_Dispose()
        {
            MyCounter.Count = 0;

            var coll = new AutoDisposeObservableCollection<MyCounter>();
            for (int i = 0; i < 10; i++)
            {
                coll.Add(new MyCounter());
            }
            coll.Remove(coll[8]);
            Assert.AreEqual(1, MyCounter.Count);
        }
        public void Replace_By_Index_Calls_Dispose()
        {
            MyCounter.Count = 0;

            var coll = new AutoDisposeObservableCollection<MyCounter>();
            for (int i = 0; i < 10; i++)
            {
                coll.Add(new MyCounter());
            }
            coll[5] = new MyCounter();
            Assert.AreEqual(1, MyCounter.Count);
        }
        public void Clear_Calls_Dispose_On_All_Items()
        {
            MyCounter.Count = 0;

            var coll = new AutoDisposeObservableCollection<MyCounter>();
            for (int i = 0; i < 10; i++)
            {
                coll.Add(new MyCounter());
            }
            coll.Clear();

            Assert.AreEqual(10, MyCounter.Count);
        }
        public void Replace_By_Index_Calls_Dispose()
        {
            MyCounter.Count = 0;

            var coll = new AutoDisposeObservableCollection <MyCounter>();

            for (int i = 0; i < 10; i++)
            {
                coll.Add(new MyCounter());
            }
            coll[5] = new MyCounter();
            Assert.AreEqual(1, MyCounter.Count);
        }
        public void Remove_By_Object_Calls_Dispose()
        {
            MyCounter.Count = 0;

            var coll = new AutoDisposeObservableCollection <MyCounter>();

            for (int i = 0; i < 10; i++)
            {
                coll.Add(new MyCounter());
            }
            coll.Remove(coll[8]);
            Assert.AreEqual(1, MyCounter.Count);
        }
        public void Clear_Calls_Dispose_On_All_Items()
        {
            MyCounter.Count = 0;

            var coll = new AutoDisposeObservableCollection <MyCounter>();

            for (int i = 0; i < 10; i++)
            {
                coll.Add(new MyCounter());
            }
            coll.Clear();

            Assert.AreEqual(10, MyCounter.Count);
        }
Пример #7
0
        public ContainerVM(IItemProvider provider, ContainerVM parent, string name, bool canRename)
            : base(provider, parent, name, canRename)
        {
            ContainerChildren = new AutoDisposeObservableCollection <ContainerVM>();
            ContainerChildren.Add(PLACE_HOLDER); // dummy self for expander

            SingleChildren = new AutoDisposeObservableCollection <ItemVM>();

            AllChildren = new CompositeCollection();
            if (IncludeContainersInAll)
            {
                AllChildren.Add(new CollectionContainer {
                    Collection = ContainerChildren
                });
            }
            AllChildren.Add(new CollectionContainer {
                Collection = SingleChildren
            });
        }