Permalink
Browse files

Merge branch 'more_covering_tests'

* more_covering_tests:
  Adding more tests to cover more code. 29 tests passing
  • Loading branch information...
2 parents 5056660 + bb05f73 commit d65c716de0d0af64431d12385bbf992ff6349e3c @fraga committed May 13, 2012
Showing with 27 additions and 3 deletions.
  1. +3 −3 GitCommands/CommitData.cs
  2. +24 −0 GitCommandsTests/CommitInformationTest.cs
@@ -109,15 +109,15 @@ public static CommitData GetCommitData(GitModule module, string sha1, ref string
if (info.Trim().StartsWith("fatal"))
{
- error = "Cannot find commit" + sha1;
+ error = "Cannot find commit " + sha1;
return null;
}
int index = info.IndexOf(sha1) + sha1.Length;
if (index < 0)
{
- error = "Cannot find commit" + sha1;
+ error = "Cannot find commit " + sha1;
return null;
}
if (index >= info.Length)
@@ -299,4 +299,4 @@ private static int IndexOfValue(string data, string header)
return valueIndex;
}
}
-}
+}
@@ -10,6 +10,7 @@ namespace GitCommandsTests
[TestClass]
public class CommitInformationTest
{
+
[TestMethod]
public void CanCreateCommitInformationFromFormatedData()
{
@@ -50,5 +51,28 @@ public void CanCreateCommitInformationFromFormatedData()
Assert.AreEqual(expectedHeader,commitInformation.Header);
Assert.AreEqual(expectedBody, commitInformation.Body);
}
+
+ [TestMethod]
+ [ExpectedException(typeof(ArgumentNullException))]
+ public void CanCreateCommitInformationFromFormatedDataThrowsException()
+ {
+ CommitInformation.GetCommitInfo(data: null);
+ }
+
+ [TestMethod]
+ public void GetCommitInfoTestWhenDataIsNull()
+ {
+ var actualResult = CommitInformation.GetCommitInfo(new GitModule(""), "fakesha1");
+ Assert.AreEqual("Cannot find commit fakesha1", actualResult.Header);
+ }
+
+ [TestMethod]
+ public void GetAllBranchesWhichContainGivenCommitTestReturnsEmptyList()
+ {
+ var actualResult = CommitInformation.GetAllBranchesWhichContainGivenCommit("fakesha1", false, false);
+
+ Assert.IsNotNull(actualResult);
+ Assert.IsTrue(!actualResult.Any());
+ }
}
}

0 comments on commit d65c716

Please sign in to comment.