예제 #1
0
        public void MakeListItemWhenRepoInUse_MakesDisabledItem()
        {
            using (var setup = new RepositorySetup("Dan"))
            {
                // Set a project up sufficiently to have an ID.
                var tempFilePath = setup.ProjectFolder.Combine("test.1w1");
                File.WriteAllText(tempFilePath, "hello");
                setup.ProjectFolderConfig.IncludePatterns.Clear();
                setup.ProjectFolderConfig.ExcludePatterns.Clear();
                setup.ProjectFolderConfig.IncludePatterns.Add("*.1w1");
                setup.AddAndCheckIn();                 // Need to have one commit.
                var id   = setup.Repository.Identifier;
                var path = setup.Repository.PathToRepo;

                var model = new CloneFromUsb();
                model.ReposInUse     = new Dictionary <string, string>();
                model.ReposInUse[id] = "myname";
                var item = model.CreateListItemFor(path);
                Assert.That(item, Is.Not.Null, "model should have made a list item");
                Assert.That(item.Text, Is.EqualTo(Path.GetFileName(path)));
                Assert.That(item.Tag, Is.EqualTo(path));
                var    last            = File.GetLastWriteTime(path);
                string expectedSubitem = last.ToShortDateString() + " " + last.ToShortTimeString();
                // Not a great test, basically duplicates the impl
                Assert.That(item.SubItems[1].Text, Is.EqualTo(expectedSubitem));
                Assert.That(item.ToolTipText, Is.EqualTo(string.Format(CloneFromUsb.ProjectInUseTemplate, "myname")));
                Assert.That(item.ImageIndex, Is.EqualTo(1));
                Assert.That(item.ForeColor, Is.EqualTo(CloneFromUsb.DisabledItemForeColor));
            }
        }
예제 #2
0
        public void IncludeFilesInSubFolders()
        {
            using (var setup = new RepositorySetup("Dan"))
            {
                var subpictures = setup.ProjectFolder.Combine("pictures", "subpictures");
                Directory.CreateDirectory(subpictures);
                var goodpicture = setup.ProjectFolder.Combine(subpictures, "good.picture");
                File.WriteAllText(goodpicture, "hello");                 // Not a real jpeg file

                var subaudio = setup.ProjectFolder.Combine("audio", "subaudio");
                Directory.CreateDirectory(subaudio);
                var goodaudio = setup.ProjectFolder.Combine(subaudio, "good.audio");
                File.WriteAllText(goodaudio, "hello");                 // Not a real mp3 file

                var subothers = setup.ProjectFolder.Combine("others", "subothers");
                Directory.CreateDirectory(subothers);
                var goodother = setup.ProjectFolder.Combine(subothers, "good.other");
                File.WriteAllText(goodother, "hello");

                setup.ProjectFolderConfig.ExcludePatterns.Clear();
                setup.ProjectFolderConfig.IncludePatterns.Clear();

                LiftFolder.AddLiftFileInfoToFolderConfiguration(setup.ProjectFolderConfig);

                setup.AddAndCheckIn();
                setup.AssertFileExistsInRepository("pictures/subpictures/good.picture");
                setup.AssertFileExistsInRepository("audio/subaudio/good.audio");
                setup.AssertFileExistsInRepository("others/subothers/good.other");
            }
        }
예제 #3
0
        public void ExcludedVideosFileNotAdded()
        {
            using (var setup = new RepositorySetup("Dan"))
            {
                var atRoot = setup.ProjectFolder.Combine("first.wmv");
                File.WriteAllText(atRoot, "hello");

                var pictures = setup.ProjectFolder.Combine("pictures");
                Directory.CreateDirectory(pictures);
                var videoExtensions = ProjectFolderConfiguration.VideoExtensions.ToList();
                foreach (var videoExtension in videoExtensions)
                {
                    var bad = Path.Combine(pictures, "nested." + videoExtension);
                    File.WriteAllText(bad, "hello");
                }

                setup.ProjectFolderConfig.ExcludePatterns.Clear();
                setup.ProjectFolderConfig.IncludePatterns.Clear();

                LiftFolder.AddLiftFileInfoToFolderConfiguration(setup.ProjectFolderConfig);

                setup.AddAndCheckIn();
                setup.AssertFileDoesNotExistInRepository("first.wmv");
                foreach (var videoExtension in videoExtensions)
                {
                    setup.AssertFileDoesNotExistInRepository("pictures/nested." + videoExtension);
                }
            }
        }
예제 #4
0
 public void NoPatternsSpecified_FileIsNotAdded()
 {
     using (var setup = new RepositorySetup("Dan"))
     {
         var path = setup.ProjectFolder.Combine("test.1w1");
         File.WriteAllText(path, "hello");
         setup.ProjectFolderConfig.IncludePatterns.Clear();
         setup.ProjectFolderConfig.ExcludePatterns.Clear();
         setup.AddAndCheckIn();
         setup.AssertFileDoesNotExistInRepository("test.1w1");
     }
 }
예제 #5
0
파일: Utf8Tests.cs 프로젝트: samdoss/chorus
        public void Utf8ExtensionPresent_LocalMercurialIniIncorrect_MercurialOpStillWorks()
        {
            using (new MercurialIniHider())
                using (var setup = new RepositorySetup("Dan"))
                {
                    const string utf8FilePath = "açesbsun.wav";
                    setup.ChangeFile(utf8FilePath, "hello1");
                    setup.ProjectFolderConfig.IncludePatterns.Add("*.wav");
                    setup.AddAndCheckIn();

                    setup.AssertFileExistsInRepository("açesbsun.wav");
                }
        }
예제 #6
0
 public void ExcludeLdmlInRoot_FileNotAdded()
 {
     using (var setup = new RepositorySetup("Dan"))
     {
         var path = setup.ProjectFolder.Combine("test.ldml");
         File.WriteAllText(path, "hello");
         setup.ProjectFolderConfig.IncludePatterns.Clear();
         setup.ProjectFolderConfig.IncludePatterns.Add("*.*");
         setup.ProjectFolderConfig.ExcludePatterns.Clear();
         setup.ProjectFolderConfig.ExcludePatterns.Add("*.ldml");
         setup.AddAndCheckIn();
         setup.AssertFileDoesNotExistInRepository("test.ldml");
     }
 }
예제 #7
0
파일: Utf8Tests.cs 프로젝트: samdoss/chorus
        public void AddUtf8FileName_CloneUpdatedFileExists()
        {
            using (var setup = new RepositorySetup("Dan"))
            {
                const string utf8FilePath = "açesbsun.wav";
                setup.ChangeFile(utf8FilePath, "hello");
                setup.ProjectFolderConfig.IncludePatterns.Add("*.wav");
                setup.AddAndCheckIn();

                using (var other = new RepositorySetup("Bob", setup))
                {
                    other.AssertFileExists(utf8FilePath);
                }
            }
        }
예제 #8
0
 public void WavFileInRepoEvenWhenExcluded()
 {
     using (var setup = new RepositorySetup("Dan"))
     {
         var path = setup.ProjectFolder.Combine("test.wav");
         File.WriteAllText(path, "hello");
         setup.ProjectFolderConfig.IncludePatterns.Clear();
         setup.ProjectFolderConfig.IncludePatterns.Add("*.*");
         setup.ProjectFolderConfig.ExcludePatterns.Clear();
         setup.ProjectFolderConfig.ExcludePatterns.Add("test.wav");
         setup.AddAndCheckIn();
         // TODO: If Hg is fixed to exclude "wav" files,
         // revise this test to assert it is *not* in repo.
         // Very important: Also fix the "wav" extension hacks in LargeFileFilter AND AudioFileTypeHandlerTests
         setup.AssertFileExistsInRepository("test.wav");
     }
 }
예제 #9
0
파일: Utf8Tests.cs 프로젝트: samdoss/chorus
        public void ChangedUtf8File_FileCanBePulledAndUpdated()
        {
            using (var setup = new RepositorySetup("Dan"))
            {
                const string utf8FilePath = "açesbsun.wav";
                setup.ChangeFile(utf8FilePath, "hello1");
                setup.ProjectFolderConfig.IncludePatterns.Add("*.wav");
                setup.AddAndCheckIn();

                using (var other = new RepositorySetup("Bob", setup))
                {
                    setup.ChangeFile(utf8FilePath, "hello2");
                    setup.Repository.Commit(false, "update");
                    other.CheckinAndPullAndMerge(setup);                     // Fix: Currently this modifies Dan adding bogus file unexpectedly.
                    other.AssertFileExists(utf8FilePath);
                    string[] fileNames = Directory.GetFiles(other.ProjectFolder.Path, "*.wav");
                    Assert.AreEqual(1, fileNames.Length);
                }
            }
        }
예제 #10
0
        public void Utf8ExtensionPresent_CloneLocalWithUpdateDoesNotHaveBogusFiles()
        {
            using (var setup = new RepositorySetup("Dan"))
            {
                const string utf8FilePath = "açesbsun.wav";
                setup.ChangeFile(utf8FilePath, "hello1");
                setup.ProjectFolderConfig.IncludePatterns.Add("*.wav");
                setup.AddAndCheckIn();

                using (var other = new RepositorySetup("Bob", false))
                {
                    setup.Repository.CloneLocalWithoutUpdate(other.ProjectFolder.Path);                     // Somewhat surprisingly this works as it is using the settings of the source hgrc during the clone
                    other.Repository.Update();

                    other.AssertFileExists(utf8FilePath);
                    string[] fileNames = Directory.GetFiles(other.ProjectFolder.Path, "*.wav");
                    Assert.AreEqual(1, fileNames.Length);
                }
            }
        }
예제 #11
0
        public void Utf8ExtensionPresent_CloneDoesNotHaveBogusFiles()
        {
            using (var setup = new RepositorySetup("Dan"))
            {
                const string utf8FilePath = "açesbsun.wav";
                setup.ChangeFile(utf8FilePath, "hello1");
                setup.ProjectFolderConfig.IncludePatterns.Add("*.wav");
                setup.AddAndCheckIn();

                using (var other = new RepositorySetup("Bob", false))
                {
                    //var uri = new Uri(String.Format("file:///{0}", setup.ProjectFolder.Path));
                    HgRepository.Clone(new DirectoryRepositorySource("utf test repo", setup.ProjectFolder.Path, false), other.ProjectFolder.Path, other.Progress);
                    other.Repository.Update();

                    other.AssertFileExists(utf8FilePath);
                    string[] fileNames = Directory.GetFiles(other.ProjectFolder.Path, "*.wav");
                    Assert.AreEqual(1, fileNames.Length);
                }
            }
        }
예제 #12
0
파일: Utf8Tests.cs 프로젝트: marksvc/chorus
        public void Utf8ExtensionNotPresent_CloneLocalWithoutUpdateThrows()
        {
            using (var setup = new RepositorySetup("Dan"))
            {
                const string utf8FilePath = "açesbsun.wav";
                setup.ChangeFile(utf8FilePath, "hello1");
                setup.ProjectFolderConfig.IncludePatterns.Add("*.wav");
                setup.AddAndCheckIn();

                using (new MercurialExtensionHider())
                    using (var other = new RepositorySetup("Bob", false))
                    {
                        Assert.Throws <ApplicationException>(
                            () => setup.Repository.CloneLocalWithoutUpdate(other.ProjectFolder.Path)
                            );
                        //string log = setup.GetProgressString();
                        //Assert.That(log, Contains.Substring("Failed to set up extensions"));
                        //Assert.IsTrue(setup.GetProgressString().Contains());
                    }
            }
        }
예제 #13
0
        public void EnsureRepoIdIsCorrect()
        {
            using (var setup = new RepositorySetup("Dan"))
            {
                var id = setup.Repository.Identifier;
                Assert.IsTrue(String.IsNullOrEmpty(id));

                var path = setup.ProjectFolder.Combine("test.1w1");
                File.WriteAllText(path, "hello");
                setup.ProjectFolderConfig.IncludePatterns.Clear();
                setup.ProjectFolderConfig.ExcludePatterns.Clear();
                setup.ProjectFolderConfig.IncludePatterns.Add("*.1w1");
                setup.AddAndCheckIn();                 // Need to have one commit.

                id = setup.Repository.Identifier;
                Assert.IsFalse(String.IsNullOrEmpty(id));

                var results = HgRunner.Run("log -r0 --template " + "\"{node}\"", setup.Repository.PathToRepo, 10, setup.Progress);
                // This will probably fail, if some other version of Hg is used,
                // as it may include multiple lines (complaining about deprecated extension Chorus uses),
                // where the last one will be the id.
                Assert.AreEqual(results.StandardOutput.Trim(), id);
            }
        }
예제 #14
0
        public void IncludeInGeneralButExcludeInSubfolder_FileNotAdded()
        {
            using (var setup = new RepositorySetup("Dan"))
            {
                var good = setup.ProjectFolder.Combine("good.lift");
                File.WriteAllText(good, "hello");

                var export = setup.ProjectFolder.Combine("export");
                Directory.CreateDirectory(export);
                var bad = Path.Combine(export, "bad.lift");
                File.WriteAllText(bad, "hello");

                var goodFontCss = Path.Combine(export, "customFonts.css");
                File.WriteAllText(goodFontCss, "hello");

                var goodLayoutCss = Path.Combine(export, "customLayout.css");
                File.WriteAllText(goodLayoutCss, "hello");

                var other = setup.ProjectFolder.Combine("other");
                Directory.CreateDirectory(other);
                var otherBad = Path.Combine(export, "otherBad.lift");
                File.WriteAllText(otherBad, "hello");

                setup.ProjectFolderConfig.ExcludePatterns.Clear();
                setup.ProjectFolderConfig.IncludePatterns.Clear();

                LiftFolder.AddLiftFileInfoToFolderConfiguration(setup.ProjectFolderConfig);

                setup.AddAndCheckIn();
                setup.AssertFileExistsInRepository("good.lift");
                setup.AssertFileExistsInRepository("export/customFonts.css");
                setup.AssertFileExistsInRepository("export/customLayout.css");
                setup.AssertFileDoesNotExistInRepository("export/bad.lift");
                setup.AssertFileDoesNotExistInRepository("other/otherBad.lift");
            }
        }