public void ShouldReorderInTopoOrder() { _revisionGraph.CacheTo(_revisionGraph.Count, _revisionGraph.Count); Assert.IsTrue(_revisionGraph.ValidateTopoOrder()); GitRevision commit1 = new GitRevision(ObjectId.Random()); GitRevision commit2 = new GitRevision(ObjectId.Random()); commit1.ParentIds = new ObjectId[] { commit2.ObjectId }; commit2.ParentIds = new ObjectId[] { _revisionGraph.GetNodeForRow(4).Objectid }; _revisionGraph.Add(commit2, RevisionNodeFlags.None); // This commit is now dangling _revisionGraph.CacheTo(_revisionGraph.Count, _revisionGraph.Count); Assert.IsTrue(_revisionGraph.ValidateTopoOrder()); _revisionGraph.Add(commit1, RevisionNodeFlags.None); // Add the connecting commit _revisionGraph.CacheTo(_revisionGraph.Count, _revisionGraph.Count); Assert.IsTrue(_revisionGraph.ValidateTopoOrder()); // Add a new head GitRevision newHead = new GitRevision(ObjectId.Random()); newHead.ParentIds = new ObjectId[] { _revisionGraph.GetNodeForRow(0).Objectid }; _revisionGraph.Add(newHead, RevisionNodeFlags.None); // Add commit that has the current top node as parent. _revisionGraph.CacheTo(_revisionGraph.Count, _revisionGraph.Count); // Call to cache fix the order Assert.IsTrue(_revisionGraph.ValidateTopoOrder()); }
public void Setup() { _revisionGraph = new RevisionGraph(); GitRevision revision = new GitRevision(ObjectId.Random()); // Mark the first revision as the current checkout _revisionGraph.Add(revision, RevisionNodeFlags.CheckedOut); }
public void Setup() { _revisionGraph = new RevisionGraph(); foreach (var revision in Revisions) { // Mark the first revision as the current checkout _revisionGraph.Add(revision, _revisionGraph.Count == 0 ? RevisionNodeFlags.CheckedOut : RevisionNodeFlags.None); } }
private void LoadRandomRevisions() { List <GitRevision> randomRevisions = new List <GitRevision>(); for (int i = 0; i < _numberOfRevisionsAddedPerRun; i++) { GitRevision revision = new GitRevision(ObjectId.Random()); if (randomRevisions.Count > 1) { revision.ParentIds = new ObjectId[] { randomRevisions[_random.Next(randomRevisions.Count - 1)].ObjectId }; } _revisionGraph.Add(revision, RevisionNodeFlags.None); randomRevisions.Add(revision); } Assert.IsTrue(_revisionGraph.GetTestAccessor().ValidateTopoOrder()); }