private void OnCurrentProjectChanged(object?sender, EventArgs eventArgs)
        {
            Items.Clear();

            if (_projectService.ProjectIsOpen)
            {
                Items.Add(_projectExplorerItemViewModelFactory.Create(_projectService.CurrentProject));
            }
        }
示例#2
0
        public ProjectRootViewModel(IProject project, IProjectExplorerItemViewModelFactory factory,
                                    IAddContextMenuItemFactory addContextMenuItemFactory) : base(project.ProjectName)
        {
            _project = project;
            _factory = factory;

            UpdateItems(_factory.Create(project.Folders, project.Files));

            ContextMenuItems.Add(addContextMenuItemFactory.Create(_project));

            project.FolderAdded += OnProjectItemsChanged;
            project.FileAdded   += OnProjectItemsChanged;
        }
示例#3
0
        public FolderViewModel(IProjectFolder folder, IProjectExplorerItemViewModelFactory factory,
                               IAddContextMenuItemFactory addContextMenuItemFactory) : base(folder.FolderName)
        {
            _folder  = folder;
            _factory = factory;

            UpdateItems(_factory.Create(_folder.Folders, _folder.Files));

            ContextMenuItems.Add(addContextMenuItemFactory.Create(folder));

            folder.FolderAdded += OnFolderItemsChanged;
            folder.FileAdded   += OnFolderItemsChanged;
        }
        public void OnCurrentProjectChanged_AddsProjectItems_WhenProjectIsOpened()
        {
            // Arrange
            var vm = GetViewModel();

            var project = Substitute.For <IProject>();
            var projectItemViewModel = new ProjectRootViewModel(project, _projectExplorerItemViewModelFactory, _addContextMenuItemFactory);

            _projectExplorerItemViewModelFactory.Create(project).Returns(projectItemViewModel);
            _projectService.CurrentProject.Returns(project);
            _projectService.ProjectIsOpen.Returns(true);

            // Act
            _projectService.CurrentProjectChanged += Raise.Event();

            // Assert
            Assert.That(vm.Items, Has.Count.EqualTo(1));
            Assert.That(vm.Items.Single(), Is.EqualTo(projectItemViewModel));
        }
示例#5
0
 private void OnProjectItemsChanged(object?sender, EventArgs eventArgs)
 {
     UpdateItems(_factory.Create(_project.Folders, _project.Files));
 }