diff options
author | Therzok <teromario@yahoo.com> | 2013-08-15 14:43:40 +0400 |
---|---|---|
committer | Therzok <teromario@yahoo.com> | 2013-08-17 22:02:34 +0400 |
commit | 15bda4a2ce8e8cc56d8572ed50d8675e503cb8e8 (patch) | |
tree | fca291365e073bb30475783ac37f83e11ce99582 /main/src | |
parent | 963d30d46d0cf93e70a71ef69c5d26431af0bd60 (diff) |
[Version Control] One more Unit Test and a fix to streamline code.
Diffstat (limited to 'main/src')
4 files changed, 58 insertions, 9 deletions
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseGitRepositoryTests.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseGitRepositoryTests.cs index 32c5b53ca4..afc0884e10 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseGitRepositoryTests.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseGitRepositoryTests.cs @@ -143,6 +143,16 @@ namespace MonoDevelop.VersionControl.Git.Tests repo2.Push (new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor (), repo2.GetCurrentRemote (), repo2.GetCurrentBranch ());
}
+ protected override void BlameExtraInternals (Annotation [] annotations)
+ {
+ for (int i = 0; i < 2; i++) {
+ Assert.IsTrue (annotations [i].HasEmail);
+ Assert.IsNotNull (annotations [i].Author);
+ Assert.IsNotNull (annotations [i].Email);
+ }
+ Assert.IsFalse (annotations [2].HasDate);
+ }
+
protected override Repository GetRepo (string path, string url)
{
return new GitRepository (path, url);
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseRepositoryTests.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseRepositoryTests.cs index 7e9c766533..fb37e56696 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseRepositoryTests.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseRepositoryTests.cs @@ -210,6 +210,7 @@ namespace MonoDevelop.VersionControl.Tests public void CorrectRevisionChanges () { AddFile ("testfile", "text", true, true); + // TODO: Extend and test each member and more types. foreach (var rev in repo.GetRevisionChanges (GetHeadRevision ())) { Assert.AreEqual (rev.Action, RevisionAction.Add); } @@ -223,7 +224,7 @@ namespace MonoDevelop.VersionControl.Tests public void RevertsRevision () { AddFile ("testfile", "text", true, true); - // Override and test in specific with GitRevision and SvnRevision. + DoRevisionRevert (); } protected virtual void DoRevisionRevert () @@ -346,24 +347,51 @@ namespace MonoDevelop.VersionControl.Tests } [Test] - [Ignore ("TODO")] + [Platform (Exclude = "Win")] + // TODO: Fix SvnSharp logic failing to generate correct URL. // Tests Repository.GetTextAtRevision. public void CorrectTextAtRevision () { - } - - protected virtual string GetTextAtRevision () - { - return null; + string added = rootCheckout + "testfile"; + AddFile ("testfile", "text1", true, true); + File.AppendAllText (added, "text2"); + CommitFile (added); + VersionInfo vi = repo.GetVersionInfo (added, VersionInfoQueryFlags.IgnoreCache); + string text = repo.GetTextAtRevision (vi.LocalPath.ToRelative (rootCheckout), GetHeadRevision ()); + Assert.AreEqual ("text1text2", text); } [Test] - [Ignore ("TODO")] // Tests Repository.GetAnnotations. public void BlameIsCorrect () { + string added = rootCheckout + "testfile"; + // Initial commit. + AddFile ("testfile", "blah" + Environment.NewLine, true, true); + // Second commit. + File.AppendAllText (added, "wut" + Environment.NewLine); + CommitFile (added); + // Working copy. + File.AppendAllText (added, "wut2" + Environment.NewLine); + + var annotations = repo.GetAnnotations (added); + for (int i = 0; i < 2; i++) { + var annotation = annotations [i]; + Assert.IsTrue (annotation.HasDate); + Assert.IsNotNull (annotation.Date); + } + + BlameExtraInternals (annotations); + + Assert.False (annotations [2].HasEmail); + Assert.IsNotNull (annotations [2].Author); + Assert.IsNull (annotations [2].Email); + Assert.AreEqual (annotations [2].Revision, GettextCatalog.GetString ("working copy")); + Assert.AreEqual (annotations [2].Author, "<uncommitted>"); } + protected abstract void BlameExtraInternals (Annotation [] annotations); + #region Util protected void Checkout (string path, string url) diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs index 67f4b23f37..8018295ada 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs @@ -1635,7 +1635,7 @@ namespace MonoDevelop.VersionControl.Git var commitTime = new DateTime (1970, 1, 1).AddSeconds (commit.CommitTime); list.Add (new Annotation (commit.Name, author.GetName (), commitTime, String.Format ("<{0}>", author.GetEmailAddress ()))); } else { - list.Add (new Annotation (new string ('0', 20), "<uncommitted>", DateTime.Now)); + list.Add (new Annotation (GettextCatalog.GetString ("working copy"), "<uncommitted>", DateTime.Now)); } } return list.ToArray (); diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Tests/BaseSvnRepositoryTests.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Tests/BaseSvnRepositoryTests.cs index 71c09ce29e..05b6cb3eae 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Tests/BaseSvnRepositoryTests.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Tests/BaseSvnRepositoryTests.cs @@ -92,6 +92,17 @@ namespace MonoDevelop.VersionControl.Subversion.Tests {
return SvnRevision.Head;
}
+
+ protected override void BlameExtraInternals (Annotation [] annotations)
+ {
+ for (int i = 0; i < 2; i++) {
+ Assert.IsFalse (annotations [i].HasEmail);
+ Assert.IsNull (annotations [i].Author);
+ Assert.IsNull (annotations [i].Email);
+ }
+ Assert.IsFalse (annotations [2].HasEmail);
+ Assert.IsFalse (annotations [2].HasDate);
+ }
}
}
|