Exemplo n.º 1
0
        public void Sync_NonExistantLangDepotProject_ExitsGracefullyWithCorrectErrorResult()
        {
            _model = new SyncControlModel(_project, SyncUIFeatures.Minimal, null);
            _model.SyncOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create("languageforge", "http://hg-public.languagedepot.org/dummy"));
            var progress = new ConsoleProgress()
            {
                ShowVerbose = true
            };

            _model.AddMessagesDisplay(progress);
            SyncResults results = null;

            _model.SynchronizeOver += new EventHandler((sender, e) => results = (sender as SyncResults));
            _model.Sync(true);
            var start = DateTime.Now;

            while (results == null)
            {
                Thread.Sleep(100);
                Application.DoEvents();            //else the background worker may starve
                if ((DateTime.Now.Subtract(start).Minutes > 1))
                {
                    Assert.Fail("Gave up waiting.");
                }
            }
            Assert.IsFalse(results.Succeeded);
            Assert.IsNotNull(results.ErrorEncountered);
        }
Exemplo n.º 2
0
 public void GetRepositoriesToList_NoRepositoriesKnown_GivesUsb()
 {
     _synchronizer.ExtraRepositorySources.Clear();
     _model = new SyncControlModel(_project, SyncUIFeatures.Advanced, null);
     _model.AddMessagesDisplay(_progress);
     Assert.AreEqual(1, _model.GetRepositoriesToList().Count);
 }
Exemplo n.º 3
0
 public void GetRepositoriesToList_NoRepositoriesKnown_GivesUsb()
 {
     _synchronizer.ExtraRepositorySources.Clear();
     _model = new SyncControlModel(_project, SyncUIFeatures.Advanced, null);
     _model.AddMessagesDisplay(_progress);
     Assert.That(_model.GetRepositoriesToList().Count, Is.EqualTo(1));
     Assert.That(_model.GetRepositoriesToList()[0].URI, Is.EqualTo("UsbKey"));
 }
Exemplo n.º 4
0
        public void Sync_Cancelled_ResultsHaveCancelledEqualsTrue()
        {
            _model = new SyncControlModel(_project, SyncUIFeatures.Minimal, null);
            _model.SyncOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create("languageforge", "https://hg-public.languageforge.org/dummy"));
            var progress = new ConsoleProgress();

            _model.AddMessagesDisplay(progress);
            SyncResults results = null;

            _model.SynchronizeOver += (sender, e) => results = sender as SyncResults;
            _model.Sync(true);
            Thread.Sleep(100);
            _model.Cancel();
            // NOTE: we can't use AutoResetEvent with Sync() - for some reason this doesn't work
            WaitForSyncToFinish(ref results);

            Assert.That(results.Succeeded, Is.False);
            Assert.That(results.Cancelled, Is.True);
            Assert.That(results.ErrorEncountered, Is.Null);
        }
Exemplo n.º 5
0
        public void Sync_NonExistentLangForgeProject_ExitsGracefullyWithCorrectErrorResult()
        {
            _model = new SyncControlModel(_project, SyncUIFeatures.Minimal, null);
            _model.SyncOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create("languageforge", "https://hg-public.languageforge.org/dummy"));
            var progress = new ConsoleProgress()
            {
                ShowVerbose = true
            };

            _model.AddMessagesDisplay(progress);
            SyncResults results = null;

            _model.SynchronizeOver += (sender, e) => results = sender as SyncResults;
            _model.Sync(true);
            // NOTE: we can't use AutoResetEvent with Sync() - for some reason this doesn't work
            WaitForSyncToFinish(ref results);

            Assert.That(results.Succeeded, Is.False);
            Assert.That(results.ErrorEncountered, Is.Not.Null);
        }
Exemplo n.º 6
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);
        }