public void CanCreateCommitInformationFromFormatedData() { var commitGuid = Guid.NewGuid(); var treeGuid = Guid.NewGuid(); var parentGuid1 = Guid.NewGuid().ToString(); var parentGuid2 = Guid.NewGuid().ToString(); var authorTime = DateTime.UtcNow.AddDays(-3); var commitTime = DateTime.UtcNow.AddDays(-2); var authorUnixTime = (int)(authorTime - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; var commitUnixTime = (int)(commitTime - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; var revisionProvider = Substitute.For <IGitRevisionProvider>(); var parent1Rev = new GitRevision(aModule: null, guid: parentGuid1) { Subject = "Parent1" }; var parent2Rev = new GitRevision(aModule: null, guid: parentGuid2) { Subject = "Parent2" }; revisionProvider.GetRevision(parentGuid1, shortFormat: true).Returns(parent1Rev); revisionProvider.GetRevision(parentGuid2, shortFormat: true).Returns(parent2Rev); var rawData = commitGuid + "\n" + treeGuid + "\n" + parentGuid1 + " " + parentGuid2 + "\n" + "John Doe (Acme Inc) <*****@*****.**>\n" + authorUnixTime + "\n" + "Jane Doe (Acme Inc) <*****@*****.**>\n" + commitUnixTime + "\n" + "\n" + "\tI made a really neato change.\n\n" + "Notes (p4notes):\n" + "\tP4@547123"; var expectedHeader = "Author:\t\t<a href='mailto:[email protected]'>John Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Author date:\t3 days ago (" + LocalizationHelpers.GetFullDateString(authorTime) + ")" + Environment.NewLine + "Committer:\t<a href='mailto:[email protected]'>Jane Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Commit date:\t2 days ago (" + LocalizationHelpers.GetFullDateString(commitTime) + ")" + Environment.NewLine + "Commit hash:\t" + commitGuid + Environment.NewLine + "Parent(s):\t<a href='gitext://gotocommit/" + parentGuid1 + "'>" + parentGuid1.Substring(0, 10) + "</a> " + parent1Rev.Subject + Environment.NewLine + " \t\t<a href='gitext://gotocommit/" + parentGuid2 + "'>" + parentGuid2.Substring(0, 10) + "</a> " + parent2Rev.Subject; var expectedBody = "\nI made a really neato change." + Environment.NewLine + Environment.NewLine + "Notes (p4notes):" + Environment.NewLine + "\tP4@547123"; var commitData = CommitData.CreateFromFormatedData(rawData, new GitModule("")); var commitInformation = CommitInformation.GetCommitInfo(revisionProvider, commitData, true); Assert.AreEqual(expectedHeader, commitInformation.Header); Assert.AreEqual(expectedBody, commitInformation.Body); }
public void CanCreateCommitInformationFromFormatedData() { LinkFactory linkFactory = new LinkFactory(); var commitGuid = Guid.NewGuid(); var treeGuid = Guid.NewGuid(); var parentGuid1 = Guid.NewGuid().ToString(); var parentGuid2 = Guid.NewGuid().ToString(); var authorTime = DateTime.UtcNow.AddDays(-3); var commitTime = DateTime.UtcNow.AddDays(-2); var authorUnixTime = (int)(authorTime - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; var commitUnixTime = (int)(commitTime - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; var rawData = commitGuid + "\n" + treeGuid + "\n" + parentGuid1 + " " + parentGuid2 + "\n" + "John Doe (Acme Inc) <*****@*****.**>\n" + authorUnixTime + "\n" + "Jane Doe (Acme Inc) <*****@*****.**>\n" + commitUnixTime + "\n" + "\n" + "\tI made a really neato change.\n\n" + "Notes (p4notes):\n" + "\tP4@547123"; var expectedHeader = "Author: <a href='mailto:[email protected]'>John Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Author date: 3 days ago (" + LocalizationHelpers.GetFullDateString(authorTime) + ")" + Environment.NewLine + "Committer: <a href='mailto:[email protected]'>Jane Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Commit date: 2 days ago (" + LocalizationHelpers.GetFullDateString(commitTime) + ")" + Environment.NewLine + "Commit hash: " + commitGuid + Environment.NewLine + "Parent(s): <a href='gitext://gotocommit/" + parentGuid1 + "'>" + parentGuid1.Substring(0, 10) + "</a> <a href='gitext://gotocommit/" + parentGuid2 + "'>" + parentGuid2.Substring(0, 10) + "</a>"; var expectedBody = "\nI made a really neato change." + Environment.NewLine + Environment.NewLine + "Notes (p4notes):" + Environment.NewLine + "\tP4@547123"; var commitData = CommitData.CreateFromFormatedData(rawData, new GitModule("")); var commitInformation = CommitInformation.GetCommitInfo(commitData, linkFactory, true); Assert.AreEqual(expectedHeader, commitInformation.Header); Assert.AreEqual(expectedBody, commitInformation.Body); }
public void CanCreateCommitInformationFromFormatedData() { var commitGuid = Guid.NewGuid(); var treeGuid = Guid.NewGuid(); var parentGuid1 = Guid.NewGuid(); var parentGuid2 = Guid.NewGuid(); var authorTime = DateTime.UtcNow.AddDays(-3); var commitTime = DateTime.UtcNow.AddDays(-2); var authorUnixTime = (int)(authorTime - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; var commitUnixTime = (int)(commitTime - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; var rawData = commitGuid + "\n" + treeGuid + "\n" + parentGuid1 + " " + parentGuid2 + "\n" + "John Doe (Acme Inc) <*****@*****.**>\n" + authorUnixTime + "\n" + "Jane Doe (Acme Inc) <*****@*****.**>\n" + commitUnixTime + "\n" + "\n" + "\tI made a really neato change.\n\n" + "Notes (p4notes):\n" + "\tP4@547123"; var expectedHeader = "Author:\t\t<a href='mailto:[email protected]'>John Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Author date:\t3 days ago (" + authorTime.ToLocalTime().ToString("ddd MMM dd HH':'mm':'ss yyyy") + ")" + Environment.NewLine + "Committer:\t<a href='mailto:[email protected]'>Jane Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Commit date:\t2 days ago (" + commitTime.ToLocalTime().ToString("ddd MMM dd HH':'mm':'ss yyyy") + ")" + Environment.NewLine + "Commit hash:\t" + commitGuid; var expectedBody = "\n\nI made a really neato change." + Environment.NewLine + Environment.NewLine + "Notes (p4notes):" + Environment.NewLine + "\tP4@547123\n\n"; var commitData = CommitData.CreateFromFormatedData(rawData); var commitInformation = CommitInformation.GetCommitInfo(commitData); Assert.AreEqual(expectedHeader, commitInformation.Header); Assert.AreEqual(expectedBody, commitInformation.Body); }