public void GeometryGraphDepthFirstEnumeratorResetTest() { // simple reset GeometryGraph graph = new GeometryGraph(PrecisionModel.Default, null, null); IGraphVertex v1 = graph.AddVertex(new Coordinate(10, 10)); IGraphVertex 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); IEnumerator <IGraphVertex> enumerator = graph.GetEnumerator(EnumerationStrategy.DepthFirst); 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))); enumerator.Reset(); 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.Reset()); }