public void Syncronhize_FileLocked_OtherFileCopied() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { System.IO.File.WriteAllText(from.Combine("test1.txt"), "Blah blah"); System.IO.File.WriteAllText(from.Combine("test2.txt"), "Blah blah blah"); var source = new RawDirectoryGroup("1", from.Path, null, null); var groups = new List <FileGroup>(new[] { source }); var progress = new StringBuilderProgress() { ShowVerbose = true }; var sync = new Synchronizer(to.Path, groups, 100, progress); using (File.OpenWrite(from.Combine("test2.txt"))) //lock it up { sync.GatherPreview(); sync.DoSynchronization(); } AssertFileExists(sync, source, to, "test1.txt"); AssertFileDoesNotExist(sync, source, to, "test2.txt"); Assert.That(progress.ErrorEncountered); } }
public void GetInfo_FileIncludedInPreviousGroup_WontBeCountedTwice() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { File.WriteAllText(from.Combine("test1.txt"), "Blah blah"); var source1 = new RawDirectoryGroup("1", from.Path, null, null); var source2 = new RawDirectoryGroup("2", from.Path, null, null); var groups = new List <FileGroup>(new[] { source1, source2 }); var progress = new StringBuilderProgress() { ShowVerbose = true }; var sync = new Synchronizer(to.Path, groups, 100, progress); sync.GatherPreview(); Assert.AreEqual(1, source1.NewFileCount); Assert.AreEqual(0, source1.UpdateFileCount); Assert.AreEqual(0, source1.DeleteFileCount); Assert.AreEqual(9, source1.NetChangeInBytes); Assert.AreEqual(0, source2.NewFileCount); Assert.AreEqual(0, source2.UpdateFileCount); Assert.AreEqual(0, source2.DeleteFileCount); Assert.AreEqual(0, source2.NetChangeInBytes); } }
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; }
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, null, true); 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, null, true); 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_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_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); }
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 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 UploadSmokeTest() { using (var folder = new TemporaryFolder("Upload Smoke Test")) { File.WriteAllText(folder.Combine("hello there.txt"), "hello there"); using (var bookZip = TempFile.WithFilenameInTempFolder("Upload Smoketest.zip")) { var zip = new BloomZipFile(bookZip.Path); zip.AddDirectory(folder.FolderPath); zip.Save(); var progress = new StringBuilderProgress(); ProblemBookUploader.UploadBook(BloomS3Client.UnitTestBucketName, bookZip.Path, progress); Assert.IsTrue(progress.Text.Contains("Success"), progress.Text); } } }
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); } }
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); }
public void Synchronize_EmptyDest_SingleFileIsBeCopied() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { System.IO.File.WriteAllText(from.Combine("1.txt"), "Blah blah"); var source = new RawDirectoryGroup("1", from.Path, null, null); var groups = new List <FileGroup>(new[] { source }); var progress = new StringBuilderProgress() { ShowVerbose = true }; var sync = new Synchronizer(to.Path, groups, 100, progress); sync.DoSynchronization(); AssertFileExists(sync, source, to, "1.txt"); } }
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); }
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 Run_ToldToSkipExtensionButSourceHasUpperCaseOfExt_DoesNotCopy() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { File.WriteAllText(from.Combine("one.TXT"), "Blah blah"); var source = new RawDirectoryGroup("1", from.Path, null, null); source.Filter.FileNameExcludes.Add("*.txt"); var groups = new List <FileGroup>(new[] { source }); var progress = new StringBuilderProgress() { ShowVerbose = true }; var sync = new MirrorController(to.Path, groups, 100, progress); sync.Run(); AssertFileDoesNotExist(sync, source, to, "one.txt"); // we don't get this progress yet Assert.That(progress.Text.ToLower().Contains("skip")); Assert.AreEqual(0, source.NewFileCount); Assert.AreEqual(0, source.UpdateFileCount); Assert.AreEqual(0, source.DeleteFileCount); } }
public void Synchronize_FolderExcluded_IsSkipped() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { Directory.CreateDirectory(from.Combine("sub")); File.WriteAllText(from.Combine("sub", "one.txt"), "Blah blah"); var source = new RawDirectoryGroup("1", from.Path, null, null); source.Filter.SubdirectoryExcludes.Add("sub"); var groups = new List <FileGroup>(new[] { source }); var progress = new StringBuilderProgress() { ShowVerbose = true }; var sync = new Synchronizer(to.Path, groups, 100, progress); sync.DoSynchronization(); // we don't get this progress yet Assert.That(progress.Text.ToLower().Contains("skip")); Assert.AreEqual(0, source.NewFileCount); Assert.AreEqual(0, source.UpdateFileCount); Assert.AreEqual(0, source.DeleteFileCount); } }
public void Setup() { _progress = new StringBuilderProgress(); }
public void Setup() { _progress = new StringBuilderProgress(); _resultDom = new XmlDocument(); }