public static void AssertNoInEdge <TVertex, TEdge>(IBidirectionalIncidenceGraph <TVertex, TEdge> graph, TVertex vertex) where TEdge : IEdge <TVertex> { Assert.IsTrue(graph.IsInEdgesEmpty(vertex)); Assert.AreEqual(0, graph.InDegree(vertex)); CollectionAssert.IsEmpty(graph.InEdges(vertex)); }
public static void AssertHasInEdges <TVertex, TEdge>( IBidirectionalIncidenceGraph <TVertex, TEdge> graph, TVertex vertex, IEnumerable <TEdge> edges) where TEdge : IEdge <TVertex> { TEdge[] edgeArray = edges.ToArray(); CollectionAssert.IsNotEmpty(edgeArray); Assert.IsFalse(graph.IsInEdgesEmpty(vertex)); Assert.AreEqual(edgeArray.Length, graph.InDegree(vertex)); CollectionAssert.AreEquivalent(edgeArray, graph.InEdges(vertex)); }
protected static void InEdges_Throws_Test <TVertex, TEdge>( IBidirectionalIncidenceGraph <TVertex, TEdge> graph) where TVertex : IEquatable <TVertex>, new() where TEdge : IEdge <TVertex> { // ReSharper disable ReturnValueOfPureMethodIsNotUsed var vertex = new TVertex(); Assert.Throws <VertexNotFoundException>(() => graph.IsInEdgesEmpty(vertex)); Assert.Throws <VertexNotFoundException>(() => graph.InDegree(vertex)); Assert.Throws <VertexNotFoundException>(() => graph.InEdges(vertex).ToArray()); // ReSharper restore ReturnValueOfPureMethodIsNotUsed }
protected static void InEdges_NullThrows_Test <TVertex, TEdge>( IBidirectionalIncidenceGraph <TVertex, TEdge> graph) where TVertex : class where TEdge : IEdge <TVertex> { // ReSharper disable ReturnValueOfPureMethodIsNotUsed // ReSharper disable AssignNullToNotNullAttribute Assert.Throws <ArgumentNullException>(() => graph.IsInEdgesEmpty(null)); Assert.Throws <ArgumentNullException>(() => graph.InDegree(null)); Assert.Throws <ArgumentNullException>(() => graph.InEdges(null).ToArray()); // ReSharper restore AssignNullToNotNullAttribute // ReSharper restore ReturnValueOfPureMethodIsNotUsed }
public static void AssertHasReversedInEdges <TVertex, TEdge>( [NotNull] IBidirectionalIncidenceGraph <TVertex, SReversedEdge <TVertex, TEdge> > graph, [NotNull] TVertex vertex, [NotNull, ItemNotNull] IEnumerable <TEdge> edges) where TEdge : IEdge <TVertex> { TEdge[] edgeArray = edges.ToArray(); CollectionAssert.IsNotEmpty(edgeArray); Assert.IsFalse(graph.IsInEdgesEmpty(vertex)); Assert.AreEqual(edgeArray.Length, graph.InDegree(vertex)); CollectionAssert.AreEquivalent( edgeArray.Select(edge => new SReversedEdge <TVertex, TEdge>(edge)), graph.InEdges(vertex)); }
protected static void InEdges_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.IsInEdgesEmpty(1)); data.CheckCalls(1); Assert.Throws <VertexNotFoundException>(() => graph.InDegree(1)); data.CheckCalls(1); Assert.Throws <VertexNotFoundException>(() => graph.InEdges(1)); data.CheckCalls(1); // ReSharper restore ReturnValueOfPureMethodIsNotUsed }