示例#1
0
        public async Task MovesSelectedFolderDown()
        {
            var foldersVM = new FoldersViewModel(fileSystemMock)
            {
                CurrentFolder = CreateMock(MockPath)
            };

            var pinnedFolders = new[] { @"C:\folder 1", @"C:\folder 2", @"C:\folder 3" };

            foreach (var pinnedFolder in pinnedFolders)
            {
                var handler = foldersVM.SelectFolder.RegisterHandler(ic => ic.SetOutput(pinnedFolder));

                await foldersVM.Pin.Execute();

                handler.Dispose();
            }

            foldersVM.Selected = foldersVM.PinnedFolders.ElementAt(2);

            Assert.False(await foldersVM.MoveSelectedPinnedFolderDown.CanExecute.FirstAsync());

            var selected = foldersVM.PinnedFolders.ElementAt(1);

            foldersVM.Selected = selected;

            Assert.True(await foldersVM.MoveSelectedPinnedFolderDown.CanExecute.FirstAsync());

            await foldersVM.MoveSelectedPinnedFolderDown.Execute();

            Assert.Equal(selected, foldersVM.PinnedFolders.ElementAt(2));
        }
示例#2
0
        public async Task ConcatenatesFoldersCorrectly()
        {
            var currentFolder = CreateMock(MockPath);

            var fsMock = new Mock <IFileSystem>();

            fsMock.Setup(fs => fs.GetSubFolders(It.IsAny <string>())).Returns(Enumerable.Empty <string>);

            var foldersVM = new FoldersViewModel(fsMock.Object)
            {
                CurrentFolder = currentFolder
            };

            var mockFolders = new[]
            {
                @"C:\SomeOtherPath1\",
                @"C:\SomeOtherPath2\",
                @"C:\SomeOtherPath3\"
            };

            foreach (var mockFolder in mockFolders)
            {
                foldersVM.SelectFolder.RegisterHandler(interaction => { interaction.SetOutput(mockFolder); });

                await foldersVM.Pin.Execute();
            }

            Assert.Equal(new[] { currentFolder.Path }.Concat(mockFolders),
                         foldersVM.AllFoldersTracked.Select(f => f.Path));
        }
示例#3
0
        public async Task CanUnpinSelected()
        {
            const string mockPathToPin = @"C:\SomeOtherPath\";

            var fsMock = new Mock <IFileSystem>();

            fsMock.Setup(fs => fs.GetSubFolders(It.IsAny <string>())).Returns(Enumerable.Empty <string>);

            var foldersVM = new FoldersViewModel(fsMock.Object)
            {
                CurrentFolder = CreateMock(MockPath)
            };

            foldersVM.SelectFolder.RegisterHandler(interaction => { interaction.SetOutput(mockPathToPin); });

            await foldersVM.Pin.Execute();

            foldersVM.Selected = foldersVM.PinnedFolders
                                 .Where(pf => pf.Path == mockPathToPin)
                                 .First();

            await foldersVM.UnpinSelected.Execute();

            Assert.DoesNotContain(mockPathToPin, foldersVM.PinnedFolders
                                  .Select(f => f.Path));
        }
示例#4
0
        public async Task <FoldersViewModel> GetFolders()
        {
            FoldersViewModel model = new FoldersViewModel();

            model.FolderList = await _folderService.GetFolders();

            return(model);
        }
示例#5
0
        private FoldersViewModel CreateFolderViewModel(int?parentNodeId, string name)
        {
            var model = new FoldersViewModel();

            model.CurrentFolder = name;
            model.SubFolders    = CreateSubfolders(parentNodeId);
            return(model);
        }
示例#6
0
        public void CurrentFolderCanBeChanged()
        {
            var foldersVM = new FoldersViewModel
            {
                CurrentFolder = CreateMock(MockPath)
            };

            Assert.Equal(MockPath, foldersVM.CurrentFolder.Path);
        }
        public ActionResult Index()
        {
            var folderResults = new FoldersViewModel();
            var folders       = dataService.GetFolders();
            var resultItems   = new List <FolderItem>();

            resultItems.AddRange(folders);
            folderResults.Items = resultItems;
            return(View("Index", folderResults));
        }
示例#8
0
        public async Task MarksCurrentFolder()
        {
            var currentFolder = CreateMock(MockPath);

            var foldersVM = new FoldersViewModel
            {
                CurrentFolder = currentFolder
            };

            Assert.True(foldersVM.CurrentFolder.IsCurrentFolder);
        }
示例#9
0
        public async Task OnlyUnpinsIfPinned()
        {
            var mockItem = CreateMock(MockPath);

            var foldersVM = new FoldersViewModel
            {
                CurrentFolder = mockItem,
                Selected      = mockItem
            };

            Assert.False(await foldersVM.UnpinSelected.CanExecute.FirstAsync());
        }
示例#10
0
        public IActionResult Index()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Intro"));
            }
            FoldersViewModel model = new FoldersViewModel();

            model.user = _userManager.GetBy(User.Identity.Name, User.Identity.Name);

            ViewData["Page.Title"]  = "Tiếng anh viết và đọc";
            ViewData["Page.Target"] = "Học phần";
            return(View(model));
        }
示例#11
0
        public async Task HandlesCancelingGracefully()
        {
            const string mockPathToPin = @"C:\SomeOtherPath\";

            var foldersVM = new FoldersViewModel
            {
                CurrentFolder = CreateMock(MockPath)
            };

            await foldersVM.Pin.Execute();

            Assert.DoesNotContain(mockPathToPin, foldersVM.PinnedFolders
                                  .Select(f => f.Path));
        }
示例#12
0
        public async Task CanPinSelected()
        {
            const string mockPathToPin = @"C:\SomeOtherPath\";

            var mockToPin = CreateMock(mockPathToPin);

            var foldersVM = new FoldersViewModel
            {
                CurrentFolder = CreateMock(MockPath)
            };

            foldersVM.Selected = mockToPin;

            await foldersVM.PinSelected.Execute();

            Assert.Contains(mockPathToPin, foldersVM.PinnedFolders
                            .Select(f => f.Path));
        }
示例#13
0
        /// <summary>
        ///		Carga los directorios de la solución
        /// </summary>
        public void LoadFolders()
        {
            // Limpia la lista de directorios
            FoldersViewModel.Items.Clear();
            // Añade los directorios de la solución
            if (MainViewModel.WorkspacesViewModel.SelectedItem != null)
            {
                foreach (string folder in MainViewModel.WorkspacesViewModel.SelectedItem.Folders)
                {
                    if (System.IO.Directory.Exists(folder))
                    {
                        ControlItemViewModel item = new ControlItemViewModel(System.IO.Path.GetFileName(folder), folder);

                        // Selecciona la carpeta
                        item.IsChecked = true;
                        // Añade el control
                        FoldersViewModel.Add(item, false);
                    }
                }
            }
        }