Exemplo n.º 1
0
        public void GetFilesInRevision_OnlyOneRevisionInRepo_GivesAllFiles()
        {
            using (var testRoot = new TemporaryFolder("ChorusRetrieveTest"))
            using (var f = new TempFileFromFolder(testRoot))
                {
                    File.WriteAllText(f.Path, "one");

                    HgRepository.CreateRepositoryInExistingDir(testRoot.Path,_progress);
                    var repo = new HgRepository(testRoot.Path, _progress);

                    repo.AddAndCheckinFile(f.Path);
                    repo.Commit(true, "initial");
                    var revisions = repo.GetAllRevisions();
                    Assert.AreEqual(1, revisions.Count);
                    var files = repo.GetFilesInRevision(revisions[0]);
                    Assert.AreEqual(1, files.Count());
                    Assert.AreEqual(f.Path, files.First().FullPath);
                }
        }
Exemplo n.º 2
0
 public void CanMakeNotesBarWithOtherFiles()
 {
     var otherFile = new TempFileFromFolder(_folder, "two.txt", "just a pretend file");
     var otherNotesFile = new TempFileFromFolder(_folder, "two.txt." + AnnotationRepository.FileExtension,
                 @"<notes version='0'>
             <annotation ref='somwhere://foo?guid=x' class='mergeConflict'>
                 <message guid='123' author='merger' status='open' date='2009-07-18T23:53:04Z'>
                     some description of the conflict
                 </message>
             </annotation>
         </notes>");
     var mapping = new NotesToRecordMapping();
     mapping.FunctionToGoFromObjectToItsId = obj => "x"; // means it looks for "x" as the id in the one.txt urls and the guid in the two.txt urls.
     var view = _system.WinForms.CreateNotesBar(_targetFile1.Path, (new List<String> {otherFile.Path}), "guid", mapping, _progress);
     view._model.SetTargetObject("myobj");
     var annotations = view._model.GetAnnotationsToShow().ToList();
     Assert.That(annotations, Has.Count.EqualTo(2), "should have obtained annotations from both files");
     ShowWindowWithControlThenClose(view);
     otherFile.Dispose();
     otherNotesFile.Dispose();
 }
Exemplo n.º 3
0
        public void ShowNotesBar()
        {
            using (var folder = new TemporaryFolder("NotesModelTests"))
            using (var dataFile = new TempFileFromFolder(folder, "one.txt", "just a pretend file"))
            using (new TempFileFromFolder(folder, "one.txt." + AnnotationRepository.FileExtension,
                @"<notes version='0'>
                    <annotation ref='somwhere://foo?id=x' class='question'>
                        <message guid='123' author='john' status='open' date='2009-07-18T23:53:04Z'>
                            Suzie, is this ok?
                        </message>
                        <message guid='222' author='suzie' status='closed' date='2009-09-19T23:53:04Z'>
                            It's fine.
                        </message>
                    </annotation>
                    <annotation ref='lift://name%20with%20space.lift?id=x' class='mergeConflict'>
                        <message guid='123' author='merger' status='open' date='2009-07-18T23:53:04Z'>
                            some description of the conflict
                        </message>
                    </annotation>
                    <annotation ref='somwhere://foo2?id=y' class='note'/>
                </notes>"))
            {
                var chorus = new ChorusSystem(folder.Path);
                var view = chorus.WinForms.CreateNotesBar(dataFile.Path, NotesToRecordMapping.SimpleForTest(), _progress);
                view.Height = 32;
                view.SetTargetObject("x");

                TextBox b = new TextBox();
                b.Location = new Point(0, 50);
                b.Text = "x";
                b.TextChanged += new EventHandler((s,e)=>view.SetTargetObject(b.Text));
                var form = new Form();
                form.Size = new Size(700, 600);
                form.Controls.Add(view);
                form.Controls.Add(b);

                Application.EnableVisualStyles();
                Application.Run(form);
            }
        }
Exemplo n.º 4
0
        public void MANUAL_ReplaceFileWithUserInteractionIfNeeded_DifferentDrives_OK()
        {
            Reporting.ErrorReport.IsOkToInteractWithUser = false;
            using (var source = new TempFile("one"))
            using (var backup = new TempFile("two"))
            {
                var drives = UsbDriveInfo.GetDrives();
                Assert.Greater(drives.Count, 0, "This test requires at least one writeable USB drive");

                var testFolder = Path.Combine(drives[0].RootDirectory.FullName, "PalasoFileUtilsUnitTests");
                Directory.CreateDirectory(testFolder);
                using (var folder = TemporaryFolder.TrackExisting(testFolder))
                using (var destination = new TempFileFromFolder(folder))
                {
                    FileUtils.ReplaceFileWithUserInteractionIfNeeded(source.Path, destination.Path, backup.Path);
                }
            }
        }
Exemplo n.º 5
0
 public void IsFileLocked_FileExistsAndIsNotLocked_ReturnsFalse()
 {
     using (var file = new TempFileFromFolder(_parentFolder))
         Assert.IsFalse(FileUtils.IsFileLocked(file.Path));
 }
Exemplo n.º 6
0
 public void IsFileLocked_FileExistsAndIsLocked_ReturnsTrue()
 {
     using (var file = new TempFileFromFolder(_parentFolder))
     {
         var stream = File.OpenWrite(file.Path);
         try
         {
             Assert.IsTrue(FileUtils.IsFileLocked(file.Path));
         }
         finally
         {
             stream.Close();
         }
     }
 }