public void Setup()
        {
            _progress = new StringBuilderProgress();
            _pathToTestRoot = Path.Combine(Path.GetTempPath(), "ChorusHistoryPaneTest"); // Don't use 'standard' ChorusTest, since it will fial, if the tests are run in seperate processes (R# 6).
            if (Directory.Exists(_pathToTestRoot))
                Directory.Delete(_pathToTestRoot, true);
            Directory.CreateDirectory(_pathToTestRoot);

            string pathToText = WriteTestFile("version one of my pretend txt");

            RepositorySetup.MakeRepositoryForTest(_pathToTestRoot, "bob",_progress);

            _project = new ProjectFolderConfiguration(_pathToTestRoot);
            _project.FolderPath = _pathToTestRoot;
            _project.IncludePatterns.Add(pathToText);
            _project.FolderPath = _pathToTestRoot;

            var revisionListOptions = new RevisionListOptions();
            revisionListOptions.RevisionsToShowFilter = ShowRevisionPredicate;

            _model = new RevisionInRepositoryModel(HgRepository.CreateOrUseExisting(_project.FolderPath, new NullProgress()),
                                                    null,
                                                    revisionListOptions);
            _model.ProgressDisplay = _progress;
        }
        /// <summary>
        /// Review: this is fragile and expensive. We're doing real internet traffic and creating real objects on S3 and parse.com
        /// which (to a very small extent) costs us real money. This will be slow. Also, under S3 eventual consistency rules,
        /// there is no guarantee that the data we just created will actually be retrievable immediately.
        /// </summary>
        /// <param name="bookName"></param>
        /// <param name="id"></param>
        /// <param name="uploader"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public Tuple <string, string> UploadAndDownLoadNewBook(string bookName, string id, string uploader, string data)
        {
            //  Create a book folder with meta.json that includes an uploader and id and some other files.
            var originalBookFolder = MakeBook(bookName, id, uploader, data);
            int fileCount          = Directory.GetFiles(originalBookFolder).Length;

            Login();
            //HashSet<string> notifications = new HashSet<string>();

            var progress = new Palaso.Progress.StringBuilderProgress();
            var s3Id     = _transfer.UploadBook(originalBookFolder, progress);

            var uploadMessages = progress.Text.Split(new string[] { "Uploading" }, StringSplitOptions.RemoveEmptyEntries);

            Assert.That(uploadMessages.Length, Is.EqualTo(fileCount + 2));             // should get one per file, plus one for metadata, plus one for book order
            Assert.That(progress.Text.Contains("Uploading book metadata"));
            Assert.That(progress.Text.Contains("Uploading " + Path.GetFileName(Directory.GetFiles(originalBookFolder).First())));

            _transfer.WaitUntilS3DataIsOnServer(originalBookFolder);
            var dest = _workFolderPath.CombineForPath("output");

            Directory.CreateDirectory(dest);
            _downloadedBooks.Clear();
            var newBookFolder = _transfer.DownloadBook(s3Id, dest);

            Assert.That(Directory.GetFiles(newBookFolder).Length, Is.EqualTo(fileCount + 1));             // book order is added during upload

            Assert.That(_downloadedBooks.Count, Is.EqualTo(1));
            Assert.That(_downloadedBooks[0].FolderPath, Is.EqualTo(newBookFolder));
            // Todo: verify that metadata was transferred to Parse.com
            return(new Tuple <string, string>(originalBookFolder, newBookFolder));
        }
 public void CommandWith10Line_CallbackOption_Get10LinesAsynchronously()
 {
     var app = "PalasoUIWindowsForms.TestApp.exe";// FileLocator.GetFileDistributedWithApplication("PalasoUIWindowsForms.TestApp.exe");
     var progress = new StringBuilderProgress();
     int linesReceivedAsynchronously = 0;
     CommandLineRunner.Run(app, "CommandLineRunnerTest", null, string.Empty, 100, progress, s => { ++linesReceivedAsynchronously; });
     Assert.AreEqual(10, linesReceivedAsynchronously);
 }
		public void CommandWith10Line_NoCallbackOption_Get10LinesSynchronously()
		{
			var progress = new StringBuilderProgress();
			var result = CommandLineRunner.Run(App, "CommandLineRunnerTest", null, string.Empty, 100,
				progress, null);
			Assert.IsTrue(result.StandardOutput.Contains("0"));
			Assert.IsTrue(result.StandardOutput.Contains("9"));
		}
 public void CommandWith10Line_NoCallbackOption_Get10LinesSynchronously()
 {
     var app = "PalasoUIWindowsForms.TestApp.exe";// FileLocator.GetFileDistributedWithApplication("PalasoUIWindowsForms.TestApp.exe");
     var progress = new StringBuilderProgress();
     int linesReceivedAsynchronously = 0;
     var result = CommandLineRunner.Run(app, "CommandLineRunnerTest", null, string.Empty, 100, progress, null);
     Assert.IsTrue(result.StandardOutput.Contains("0"));
     Assert.IsTrue(result.StandardOutput.Contains("9"));
 }
		public void CommandWith10Line_NoCallbackOption_TimeoutAfter3s()
		{
			var progress = new StringBuilderProgress();
			var result = CommandLineRunner.Run(App, "CommandLineRunnerTest", null, string.Empty, 3,
				progress, null);
			Assert.That(result.DidTimeOut, Is.True);
			Assert.That(result.StandardOutput, Is.Null);
			Assert.That(result.StandardError, Contains.Substring("Timed Out after waiting 3 seconds."));
		}
		public void CommandWith10Line_CallbackOption_Get10LinesAsynchronously()
		{
			var progress = new StringBuilderProgress();
			int linesReceivedAsynchronously = 0;
			CommandLineRunner.Run(App, "CommandLineRunnerTest", null, string.Empty, 100,
				progress, s => ++linesReceivedAsynchronously);
			// The test fails on Linux because progress gets called 10x for StdOutput plus
			// 1x for StdError (probably on the closing of the stream), so linesReceivedAsync is 11.
			Assert.AreEqual(10, linesReceivedAsynchronously);
		}
        public void ShowAndDoWork(Action<IProgress, DoWorkEventArgs> work)
        {
            Progress.ProgressIndicator = ProgressBar;

            Progress.AddStatusProgress(StatusLabel);
            ProgressString = new StringBuilderProgress();
            Progress.AddMessageProgress(ProgressString);
            //Progress.AddMessageProgress(_messageLabelProgress);
            _backgroundWorker.RunWorkerCompleted += (sender, e) => Close();
            _backgroundWorker.WorkerReportsProgress = true;
            _backgroundWorker.WorkerSupportsCancellation = true;
            _backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(_backgroundWorker_ProgressChanged);
            _backgroundWorker.DoWork += (sender, arg) => work(Progress, arg);
            ShowDialog();
        }
 public void ShowAndDoWork(Action<IProgress> work)
 {
     _work = work;
     Progress.ProgressIndicator = ProgressBar;
     Progress.AddStatusProgress(_status);
     Progress.AddMessageProgress(_messageLabelProgress);
     Progress.Add(new ApplicationDoEventsProgress());//this will keep our UI alive
     var stringProgress = new StringBuilderProgress();
     Progress.Add(stringProgress);
     Application.Idle += StartWorking;
     ShowDialog();
     if (Progress.ErrorEncountered)
     {
         Palaso.Reporting.ErrorReport.NotifyUserOfProblem("There was a problem performing that operation.\r\n\r\n"+stringProgress.Text);
     }
 }
Exemple #10
0
        public void Setup()
        {
            _progress = new StringBuilderProgress();
            _pathToTestRoot = Path.Combine(Path.GetTempPath(), "ChorusTest");
            Directory.CreateDirectory(_pathToTestRoot);

            _pathToText = Path.Combine(_pathToTestRoot, "foo.txt");
            File.WriteAllText(_pathToText, "version one of my pretend txt");

            RepositorySetup.MakeRepositoryForTest(_pathToTestRoot, "bob",_progress);

            _project = new ProjectFolderConfiguration(_pathToTestRoot);
            _project.FolderPath = _pathToTestRoot;
            _project.IncludePatterns.Add(_pathToText);
            _project.FolderPath = _pathToTestRoot;

            _repository = new HgRepository(_project.FolderPath, _progress);
        }
Exemple #11
0
 private bool IsSharedFolderRepositoryReachable(RepositoryAddress repoAddress, out string logString)
 {
     // We want to know if we can connect, but we don't want to bother the user with extraneous information.
     // But we DO want the diagnostic information available.
     logString = string.Empty;
     var progress = new StringBuilderProgress() { ShowVerbose = true };
     var result = repoAddress.CanConnect(_repository, "", progress);
     if (!result)
         logString = progress.Text;
     return result;
 }
Exemple #12
0
 private bool IsInternetRepositoryReachable(RepositoryAddress repoAddress, out string logString)
 {
     logString = string.Empty;
     var progress = new StringBuilderProgress(){ShowVerbose = true};
     var result = repoAddress.CanConnect(_repository, repoAddress.Name, progress);
     if (!result)
         logString = progress.Text;
     return result;
 }
		public void Setup()
		{
			_progress = new StringBuilderProgress();
			_resultDom = new XmlDocument();
		}
Exemple #14
0
        public void Setup()
        {
            _progress = new StringBuilderProgress();
            _pathToTestRoot = Path.Combine(Path.GetTempPath(), "ChorusTest");
            Directory.CreateDirectory(_pathToTestRoot);

            string pathToText = Path.Combine(_pathToTestRoot, "foo.txt");
            File.WriteAllText(pathToText, "version one of my pretend txt");

            RepositorySetup.MakeRepositoryForTest(_pathToTestRoot, "bob",_progress);

            _project = new ProjectFolderConfiguration(_pathToTestRoot);
            _project.FolderPath = _pathToTestRoot;
            _project.IncludePatterns.Add(pathToText);
            _project.FolderPath = _pathToTestRoot;

            _synchronizer = Synchronizer.FromProjectConfiguration(_project, new NullProgress());
            _model = new SyncControlModel(_project, SyncUIFeatures.Advanced,null);
            _model.AddMessagesDisplay(_progress);
        }
		public void Setup()
		{
			_progress = new StringBuilderProgress();
		}