コード例 #1
0
        public void RefreshOfMultiSelectionProperty_RefreshesAllItemsAndSelectedItems()
        {
            var allGroups = new List <Group> {
                Group1
            };
            var selectedGroups = new List <Group> {
                Group1
            };

            UserVM vm = CreateUserVM(
                allGroupsSelector: x => allGroups,
                selectedGroupsSelector: x => selectedGroups
                );

            Assert.AreEqual(1, vm.Groups.SelectedItems.Count); // Trigger initial load

            allGroups = new List <Group> {
                Group2
            };
            selectedGroups = new List <Group> {
                Group2
            };

            vm.RefreshGroups();

            AssertAllItemsAreEqual(vm, allGroups);
            CollectionAssert.AreEqual(
                selectedGroups,
                vm.Groups.SelectedItems.Select(x => x.Source).ToArray()
                );
        }
コード例 #2
0
        public void UpdateFromSource_RaisesExpectedEvents()
        {
            var allGroups = new List <Group> {
                Group1
            };
            var selectedGroups = new List <Group> {
                Group1
            };

            UserVM vm = CreateUserVM(
                allGroupsSelector: x => allGroups,
                selectedGroupsSelector: x => selectedGroups
                );

            Assert.AreEqual(1, vm.Groups.SelectedItems.Count); // Trigger initial load

            allGroups = new List <Group> {
                Group2
            };
            selectedGroups = new List <Group> {
                Group2
            };

            string eventSequence = "|";

            vm.Groups.PropertyChanged += (_, e) => {
                if (e.PropertyName == "SelectedItems")
                {
                    eventSequence += ("PropertyChanged" + "|");
                }
            };

            ((IBindingList)vm.Groups.AllItems).ListChanged += (_, e) => {
                eventSequence += ("ListChanged" + "|");
            };

            vm.RefreshGroups();

            Assert.IsTrue(eventSequence.Contains("|ListChanged|PropertyChanged|")); // TODO: Investigate why so many events are raised.
        }
コード例 #3
0
        public void UpdateFromSource()
        {
            UserVM vm = CreateUserVMWithItems();

            vm.RefreshGroups();
        }