public void GeometryGraphBreathFirstEnumeratorMoveNextTest() { // empty graph GeometryGraph graph = new GeometryGraph(PrecisionModel.Default, null, null); IEnumerator <IGraphVertex> enumerator = graph.GetEnumerator(EnumerationStrategy.BreathFirst); Assert.IsNull(enumerator.Current); Assert.IsFalse(enumerator.MoveNext()); Assert.IsNull(enumerator.Current); // weekly connected graph graph = new GeometryGraph(PrecisionModel.Default, null, null); IGraphVertex v1 = graph.AddVertex(new Coordinate(10, 10)); IGraphVertex v2 = graph.AddVertex(new Coordinate(0, 0)); graph.AddEdge(v1, v2); enumerator = graph.GetEnumerator(EnumerationStrategy.BreathFirst); List <IGraphVertex> list = new List <IGraphVertex>(); while (enumerator.MoveNext()) { list.Add(enumerator.Current); } Assert.AreEqual(list.Count, graph.VertexCount); Assert.IsTrue(list.All(vertex => graph.Vertices.Contains(vertex))); // strongly connected graph graph = new GeometryGraph(PrecisionModel.Default, null, null); v1 = graph.AddVertex(new Coordinate(10, 10)); v2 = graph.AddVertex(new Coordinate(0, 0)); graph.AddEdge(v1, v2); graph.AddEdge(v2, v1); enumerator = graph.GetEnumerator(EnumerationStrategy.BreathFirst); list = new List <IGraphVertex>(); while (enumerator.MoveNext()) { list.Add(enumerator.Current); } Assert.AreEqual(list.Count, graph.VertexCount); Assert.IsTrue(list.All(vertex => graph.Vertices.Contains(vertex))); // disconnected graph graph = new GeometryGraph(PrecisionModel.Default, null, null); v1 = graph.AddVertex(new Coordinate(10, 10)); v2 = graph.AddVertex(new Coordinate(0, 0)); IGraphVertex v3 = graph.AddVertex(new Coordinate(5, 5)); IGraphVertex v4 = graph.AddVertex(new Coordinate(15, 15)); graph.AddEdge(v1, v2); graph.AddEdge(v2, v1); graph.AddEdge(v3, v4); enumerator = graph.GetEnumerator(EnumerationStrategy.BreathFirst); list = new List <IGraphVertex>(); while (enumerator.MoveNext()) { list.Add(enumerator.Current); } Assert.AreEqual(list.Count, graph.VertexCount); Assert.IsTrue(list.All(vertex => graph.Vertices.Contains(vertex))); // modified collection graph.AddVertex(new Coordinate(20, 20)); Assert.Throws <InvalidOperationException>(() => enumerator.MoveNext()); }