public void ToString2() { ToStringTest(1, 2, 3, 4); ToStringTest( new TestVertex("1"), new TestVertex("2"), new TestVertex("3"), new TestVertex("4")); ToStringTest( new EquatableTestVertex("1"), new EquatableTestVertex("2"), new EquatableTestVertex("3"), new EquatableTestVertex("4")); #region Local function void ToStringTest <TVertex>( TVertex vertex1, TVertex vertex2, TVertex vertex3, TVertex vertex4) { var queue = new BinaryQueue <TVertex, double>(_ => 1.0); // Empty heap => consistent StringAssert.StartsWith(Consistent, queue.ToString2()); queue.Enqueue(vertex1); queue.Enqueue(vertex2); queue.Enqueue(vertex2); queue.Enqueue(vertex3); queue.Enqueue(vertex1); StringAssert.StartsWith(Consistent, queue.ToString2()); queue.Dequeue(); queue.Dequeue(); StringAssert.StartsWith(Consistent, queue.ToString2()); queue.Dequeue(); queue.Dequeue(); queue.Dequeue(); StringAssert.StartsWith(Consistent, queue.ToString2()); queue.Enqueue(vertex4); StringAssert.StartsWith(Consistent, queue.ToString2()); } #endregion }