public void ShouldReorderInTopoOrder() { _revisionGraph.CacheTo(_revisionGraph.Count, _revisionGraph.Count); Assert.IsTrue(_revisionGraph.GetTestAccessor().ValidateTopoOrder()); GitRevision commit1 = new(ObjectId.Random()); GitRevision commit2 = new(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.GetTestAccessor().ValidateTopoOrder()); _revisionGraph.Add(commit1, RevisionNodeFlags.None); // Add the connecting commit _revisionGraph.CacheTo(_revisionGraph.Count, _revisionGraph.Count); Assert.IsTrue(_revisionGraph.GetTestAccessor().ValidateTopoOrder()); // Add a new head GitRevision newHead = new(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.GetTestAccessor().ValidateTopoOrder()); }
public void ShouldReorderInTopoOrder() { for (int i = 0; i < _numberOfRepeats; i++) { // Simulate thread that loads revisions from git var loadRevisionsTask = new Task(() => LoadRandomRevisions()); // Simulate thread that caches the rows in the background var buildCacheTask = new Task(() => BuildCache()); // Simulate thread that renders var renderTask = new Task(() => Render()); loadRevisionsTask.Start(); buildCacheTask.Start(); renderTask.Start(); Task.WaitAll(loadRevisionsTask, buildCacheTask, renderTask); // One last 'cache to', in case the loading of the revisions was finished after building the cache (unlikely) _revisionGraph.CacheTo(_revisionGraph.Count, _revisionGraph.Count); // Validate topo order Assert.IsTrue(_revisionGraph.GetTestAccessor().ValidateTopoOrder()); } }