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)); }
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)); }
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)); }
public async Task <FoldersViewModel> GetFolders() { FoldersViewModel model = new FoldersViewModel(); model.FolderList = await _folderService.GetFolders(); return(model); }
private FoldersViewModel CreateFolderViewModel(int?parentNodeId, string name) { var model = new FoldersViewModel(); model.CurrentFolder = name; model.SubFolders = CreateSubfolders(parentNodeId); return(model); }
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)); }
public async Task MarksCurrentFolder() { var currentFolder = CreateMock(MockPath); var foldersVM = new FoldersViewModel { CurrentFolder = currentFolder }; Assert.True(foldersVM.CurrentFolder.IsCurrentFolder); }
public async Task OnlyUnpinsIfPinned() { var mockItem = CreateMock(MockPath); var foldersVM = new FoldersViewModel { CurrentFolder = mockItem, Selected = mockItem }; Assert.False(await foldersVM.UnpinSelected.CanExecute.FirstAsync()); }
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)); }
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)); }
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)); }
/// <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); } } } }