Пример #1
0
        public void LocalListFiles()
        {            
            BrowserPresenter presenter = new BrowserPresenter("Local", new LocalBrowserModel(), null, new MockFileTransferPresenter());
            IBrowserViewModel viewModel = presenter.ViewModel;

            // make mock dir
            String testDir = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
            File.Delete(testDir);
            Directory.CreateDirectory(Path.Combine(testDir, "A"));
            Directory.CreateDirectory(Path.Combine(testDir, "B"));
            Directory.CreateDirectory(Path.Combine(testDir, "C"));
            File.WriteAllText(Path.Combine(testDir, "file1"), "");
            File.WriteAllText(Path.Combine(testDir, "file2"), "");
            File.WriteAllText(Path.Combine(testDir, "file3"), "");
            File.WriteAllText(Path.Combine(testDir, "file4"), "1");

            // change to mode dir
            presenter.ViewModel.PropertyChanged+= (s, e) => 
            {
                if (presenter.ViewModel.BrowserState == BrowserState.Ready)
                {
                    lock (this) { Monitor.Pulse(this);  }
                }
            };
            presenter.LoadDirectory(new BrowserFileInfo(new DirectoryInfo(testDir)));
            lock (this)
            {
                Monitor.Wait(this, 1000);
            }

            foreach (BrowserFileInfo bfi in presenter.ViewModel.Files)
            {
                Log.InfoFormat("BFI: {0}", bfi);
            }
            Assert.IsNotNull(viewModel.Files);
            Assert.AreEqual(8, viewModel.Files.Count);
            Assert.AreEqual("..", viewModel.Files[0].Name);
            Assert.AreEqual(new DirectoryInfo(Path.GetTempPath()), new DirectoryInfo(viewModel.Files[0].Path));
            Assert.AreEqual(FileType.ParentDirectory, viewModel.Files[0].Type);
            Assert.AreEqual("A", viewModel.Files[1].Name);
            Assert.AreEqual(FileType.Directory, viewModel.Files[1].Type);
            Assert.AreEqual(0, viewModel.Files[1].Size);

            Assert.AreEqual("file1", viewModel.Files[4].Name, "file1");
            Assert.AreEqual(FileType.File, viewModel.Files[4].Type);
            Assert.AreEqual(0, viewModel.Files[4].Size);

            Assert.AreEqual(1, viewModel.Files[7].Size);
        }
Пример #2
0
        public PscpBrowserPanel(SessionData session, PscpOptions options, string localStartingDir) : this()
        {
            Name    = session.SessionName;
            TabText = session.SessionName;

            //set the remote path
            String remotePath;

            if (String.IsNullOrEmpty(session.RemotePath))
            {
                remotePath = options.PscpHomePrefix + session.Username;
            }
            else
            {
                remotePath = session.RemotePath;
            }

            //set the local path
            String localPath;

            if (String.IsNullOrEmpty(localStartingDir))
            {
                localPath = String.IsNullOrEmpty(session.LocalPath) ? Environment.GetFolderPath(Environment.SpecialFolder.Desktop) : session.LocalPath;
            }
            else
            {
                localPath = localStartingDir;
            }


            var fileTransferPresenter = new FileTransferPresenter(options);
            IBrowserPresenter localBrowserPresenter = new BrowserPresenter(
                "Local", new LocalBrowserModel(), session, fileTransferPresenter);
            IBrowserPresenter remoteBrowserPresenter = new BrowserPresenter(
                "Remote", new RemoteBrowserModel(options), session, fileTransferPresenter);

            browserViewLocal.Initialize(localBrowserPresenter, new BrowserFileInfo(new DirectoryInfo(localPath)));
            browserViewRemote.Initialize(remoteBrowserPresenter, RemoteBrowserModel.NewDirectory(remotePath));
            fileTransferView.Initialize(fileTransferPresenter);
        }
Пример #3
0
        public void TestGUI()
        {
            BrowserPresenter presenter = new BrowserPresenter(
                "Local", new LocalBrowserModel(), new SessionData(), new MockFileTransferPresenter());

            string dir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            BrowserView view = new BrowserView(presenter, new BrowserFileInfo(new DirectoryInfo(dir)));
            view.Dock = DockStyle.Fill;

            Form form = new Form();
            form.Size = new Size(600, 800);
            form.Controls.Add(view);
            form.ShowDialog();
        }
Пример #4
0
        public void TestGUI()
        {
            Form form = new Form();
            form.Size = new Size(600, 800);

            SessionData session = new SessionData
            {
                Username = ScpConfig.UserName,
                Password = ScpConfig.Password, 
                Host = ScpConfig.KnownHost, 
                Port = 22
            };

            BrowserPresenter presenter = new BrowserPresenter(
                "Remote",
                new RemoteBrowserModel(ScpConfig.DefaultOptions), 
                session, 
                new MockFileTransferPresenter());

            BrowserView view = new BrowserView(
                presenter,
                RemoteBrowserModel.NewDirectory("/home/" + ScpConfig.UserName));
            view.Dock = DockStyle.Fill;

            form.Controls.Add(view);
            form.ShowDialog();
        }