コード例 #1
0
        public void GetValueOfSelectedItems_DoesNotLoadAllItems()
        {
            var vm = CreateUserVMWithItems();

            vm.Groups.GetValue(x => x.SelectedItems);
            ViewModelAssert.IsNotLoaded(vm.Groups, x => x.AllItems);
        }
コード例 #2
0
        public void GetValueOfSelectedItem_DoesNotLoadAllItems()
        {
            var vm = CreateUserVMWithItems();

            vm.Department.GetValue(x => x.SelectedItem);
            ViewModelAssert.IsNotLoaded(vm.Department, x => x.AllItems);
        }
コード例 #3
0
        public void SetSelectedSourceItems_DoesNotLoadAllItems()
        {
            var vm = CreateUserVMWithItems();

            vm.Groups.Load(x => x.SelectedItems);
            vm.Groups.SelectedSourceItems = new[] { Group1, Group3 };
            ViewModelAssert.IsNotLoaded(vm.Groups, x => x.AllItems);
        }
コード例 #4
0
        public void SetSelectedSourceItem_DoesNotLoadAllItems()
        {
            var vm = CreateUserVMWithItems();

            vm.Department.Load(x => x.SelectedItem);
            vm.Department.SelectedSourceItem = Department2;
            ViewModelAssert.IsNotLoaded(vm.Department, x => x.AllItems);
        }
コード例 #5
0
        public void Revalidate_DoesNotLoadAllItems()
        {
            var vm = CreateUserVMWithItems();

            vm.Groups.Load(x => x.SelectedItems);
            vm.Groups.Revalidate(ValidationScope.SelfAndLoadedDescendants);

            ViewModelAssert.IsNotLoaded(vm.Groups, x => x.AllItems);
        }
コード例 #6
0
        public void RefreshDescendants_DoesNotLoadUnloadedProperties()
        {
            var root = new RootVM();

            root.RefreshDescendants(b => {
                b.Descendant(x => x.Children)
                .Properties(x => x.RefreshDetectionProperty);
            });

            ViewModelAssert.IsNotLoaded(root, x => x.Children);
        }
コード例 #7
0
        public void AddChildToCollection_AfterRevalidateAllDescendantsHasBeenCalled_DoesLoadDescendantsOfNewChild()
        {
            VM.Revalidate(ValidationScope.SelfAndAllDescendants);

            var newChild = new ChildVM {
                Source = new ChildSource {
                    Items = new List <GrandchildSource> {
                        new GrandchildSource()
                    }
                }
            };

            ViewModelAssert.IsNotLoaded(newChild, x => x.Items);

            VM.GetValue(x => x.Children).Add(newChild);
            ViewModelAssert.IsNotLoaded(newChild, x => x.Items);
        }
コード例 #8
0
        public void RollbackTo_WhenCollectionLoadedAfterRollbackPoint_DoesNotClearCollection()
        {
            Employee employee = new Employee();

            employee.Projects.Add(new Project());

            EmployeeVM.InitializeFrom(employee);

            IRollbackPoint rollbackPoint = EmployeeVM.UndoManager.GetRollbackPoint();

            ViewModelAssert.IsNotLoaded(EmployeeVM, x => x.Projects);
            EmployeeVM.Load(x => x.Projects);
            Assert.AreEqual(1, EmployeeVM.Projects.Count);

            EmployeeVM.UndoManager.RollbackTo(rollbackPoint);

            ViewModelAssert.IsLoaded(EmployeeVM, x => x.Projects);
            Assert.AreEqual(1, EmployeeVM.Projects.Count);
        }
コード例 #9
0
        public void GetDescendants_WhenOnlyLoadedIsTrue_DoesNotLoadDescendants()
        {
            var unloadedProject = new ProjectVM();
            var loadedProject   = new ProjectVM();

            var selectedCustomer = new CustomerVM();
            var customerItem     = new CustomerVM();

            loadedProject.SetValue(x => x.SelectedCustomer, selectedCustomer);
            loadedProject.GetValue(x => x.Customers).Add(customerItem);

            var rootVM = new EmployeeVM();

            var projects = rootVM.GetValue(x => x.Projects);

            projects.Add(unloadedProject);
            projects.Add(loadedProject);

            var path = PathDefinition
                       .Empty
                       .Append((EmployeeVMDescriptor x) => x.Projects)
                       .Append((ProjectVMDescriptor x) => x.SelectedCustomer);

            var descenantViewModels = path.GetLoadedDescendants(rootVM);

            CollectionAssert.AreEquivalent(new[] { selectedCustomer }, descenantViewModels);
            ViewModelAssert.IsNotLoaded(unloadedProject, x => x.SelectedCustomer);

            path = PathDefinition
                   .Empty
                   .Append((EmployeeVMDescriptor x) => x.Projects)
                   .Append((ProjectVMDescriptor x) => x.Customers);

            descenantViewModels = path.GetLoadedDescendants(rootVM);

            CollectionAssert.AreEquivalent(new[] { customerItem }, descenantViewModels);
            ViewModelAssert.IsNotLoaded(unloadedProject, x => x.Customers);
        }
コード例 #10
0
 public void IsLoaded_WhenCacheIsNotPopulated_ReturnsFalse()
 {
     ViewModelAssert.IsNotLoaded(VM, x => x.MappedProperty);
 }