protected static void InEdge_ImmutableGraph_ReversedTest( IMutableVertexAndEdgeSet <int, Edge <int> > wrappedGraph, Func <IBidirectionalIncidenceGraph <int, SReversedEdge <int, Edge <int> > > > createGraph) { var edge11 = new Edge <int>(1, 1); var edge31 = new Edge <int>(3, 1); var edge32 = new Edge <int>(3, 2); var edge34 = new Edge <int>(3, 4); wrappedGraph.AddVerticesAndEdgeRange(new[] { edge11, edge31, edge32, edge34 }); IBidirectionalIncidenceGraph <int, SReversedEdge <int, Edge <int> > > graph = createGraph(); AssertSameReversedEdge(edge11, graph.InEdge(1, 0)); AssertSameReversedEdge(edge31, graph.InEdge(3, 0)); AssertSameReversedEdge(edge34, graph.InEdge(3, 2)); }
protected static void InEdge_ImmutableGraph_Test( IMutableVertexAndEdgeSet <int, Edge <int> > wrappedGraph, Func <IBidirectionalIncidenceGraph <int, Edge <int> > > createGraph) { var edge11 = new Edge <int>(1, 1); var edge13 = new Edge <int>(1, 3); var edge21 = new Edge <int>(2, 1); var edge41 = new Edge <int>(4, 1); wrappedGraph.AddVerticesAndEdgeRange(new[] { edge11, edge13, edge21, edge41 }); IBidirectionalIncidenceGraph <int, Edge <int> > graph = createGraph(); Assert.AreSame(edge11, graph.InEdge(1, 0)); Assert.AreSame(edge41, graph.InEdge(1, 2)); Assert.AreSame(edge13, graph.InEdge(3, 0)); }
protected static void InEdge_Test( [NotNull] GraphData <int, Edge <int> > data, [NotNull] IBidirectionalIncidenceGraph <int, Edge <int> > graph) { var edge11 = new Edge <int>(1, 1); var edge21 = new Edge <int>(2, 1); var edge31 = new Edge <int>(3, 1); data.CheckCalls(0); data.ShouldReturnValue = true; data.ShouldReturnEdges = new[] { edge11, edge21, edge31 }; Assert.AreSame(edge11, graph.InEdge(1, 0)); data.CheckCalls(1); Assert.AreSame(edge31, graph.InEdge(1, 2)); data.CheckCalls(1); }
protected static void InEdge_NullThrows_Test <TVertex, TEdge>( IBidirectionalIncidenceGraph <TVertex, TEdge> graph) where TVertex : class where TEdge : IEdge <TVertex> { // ReSharper disable once ReturnValueOfPureMethodIsNotUsed // ReSharper disable once AssignNullToNotNullAttribute Assert.Throws <ArgumentNullException>(() => graph.InEdge(null, 0)); }
protected static void InEdge_Throws_Test( [NotNull] GraphData <int, Edge <int> > data, [NotNull] IBidirectionalIncidenceGraph <int, Edge <int> > graph) { // ReSharper disable ReturnValueOfPureMethodIsNotUsed data.CheckCalls(0); data.ShouldReturnValue = false; Assert.Throws <VertexNotFoundException>(() => graph.InEdge(1, 0)); data.CheckCalls(1); data.ShouldReturnValue = true; AssertIndexOutOfRange(() => graph.InEdge(1, 0)); data.CheckCalls(1); data.ShouldReturnEdges = new[] { new Edge <int>(1, 2) }; AssertIndexOutOfRange(() => graph.InEdge(1, 1)); data.CheckCalls(1); // ReSharper restore ReturnValueOfPureMethodIsNotUsed }
protected static void InEdge_Throws_ImmutableGraph_ReversedTest( IMutableVertexAndEdgeSet <int, Edge <int> > wrappedGraph, Func <IBidirectionalIncidenceGraph <int, SReversedEdge <int, Edge <int> > > > createGraph) { const int vertex1 = 1; const int vertex2 = 2; // ReSharper disable ReturnValueOfPureMethodIsNotUsed IBidirectionalIncidenceGraph <int, SReversedEdge <int, Edge <int> > > graph = createGraph(); Assert.Throws <VertexNotFoundException>(() => graph.InEdge(vertex1, 0)); wrappedGraph.AddVertex(vertex1); wrappedGraph.AddVertex(vertex2); graph = createGraph(); AssertIndexOutOfRange(() => graph.InEdge(vertex1, 0)); wrappedGraph.AddEdge(new Edge <int>(1, 2)); graph = createGraph(); AssertIndexOutOfRange(() => graph.InEdge(vertex1, 5)); // ReSharper restore ReturnValueOfPureMethodIsNotUsed }