TestEdgeToVerticesBad7() { // Second vertex has no parent. try { MockVertex oVertex1 = new MockVertex(); MockVertex oVertex2 = new MockVertex(); IGraph oGraph = new Graph(); oVertex1.ParentGraph = oGraph; // oVertex2.ParentGraph = oGraph; IEdge oEdge = new MockEdge(oVertex1, oVertex2, false, false, 2); IVertex oVertexA, oVertexB; EdgeUtil.EdgeToVertices(oEdge, ClassName, MethodOrPropertyName, out oVertexA, out oVertexB); } catch (ApplicationException oApplicationException) { Assert.AreEqual( "TheClass.TheMethodOrProperty: The edge's second vertex does" + " not belong to a graph." , oApplicationException.Message ); throw oApplicationException; } }
TestEdgeToVerticesBad3() { // Edge.Vertices contains 1 vertex only. try { IEdge oEdge = new MockEdge(null, null, false, false, 1); IVertex oVertexA, oVertexB; EdgeUtil.EdgeToVertices(oEdge, ClassName, MethodOrPropertyName, out oVertexA, out oVertexB); } catch (ApplicationException oApplicationException) { Assert.AreEqual( "TheClass.TheMethodOrProperty: The edge does not connect two" + " vertices." , oApplicationException.Message ); throw oApplicationException; } }
TestEdgeToVerticesBad5() { // Second vertex is null. try { IEdge oEdge = new MockEdge( new MockVertex(), null, false, false, 2); IVertex oVertexA, oVertexB; EdgeUtil.EdgeToVertices(oEdge, ClassName, MethodOrPropertyName, out oVertexA, out oVertexB); } catch (ApplicationException oApplicationException) { Assert.AreEqual( "TheClass.TheMethodOrProperty: The edge's second vertex is" + " null." , oApplicationException.Message ); throw oApplicationException; } }
TestEdgeToVerticesBad8() { // Vertices not part of the same graph. try { MockVertex oVertex1 = new MockVertex(); MockVertex oVertex2 = new MockVertex(); IGraph oGraph1 = new Graph(GraphDirectedness.Mixed); IGraph oGraph2 = new Graph(GraphDirectedness.Mixed); oVertex1.ParentGraph = oGraph1; oVertex2.ParentGraph = oGraph2; IEdge oEdge = new MockEdge(oVertex1, oVertex2, false, false, 2); IVertex oVertexA, oVertexB; EdgeUtil.EdgeToVertices(oEdge, ClassName, MethodOrPropertyName, out oVertexA, out oVertexB); } catch (ApplicationException oApplicationException) { Assert.AreEqual( "TheClass.TheMethodOrProperty: The edge connects vertices not" + " in the same graph." , oApplicationException.Message ); throw oApplicationException; } }
TestEdgeToVerticesBad() { // Null Edge.Vertices. try { IEdge oEdge = new MockEdge(null, null, false, true, 0); IVertex oVertexA, oVertexB; EdgeUtil.EdgeToVertices(oEdge, ClassName, MethodOrPropertyName, out oVertexA, out oVertexB); } catch (ApplicationException ApplicationException) { Assert.AreEqual( "TheClass.TheMethodOrProperty: The edge's Vertices property is" + " null." , ApplicationException.Message ); throw ApplicationException; } }
TestEdgeToVertices() { // Valid vertices. MockVertex oVertex1 = new MockVertex(); MockVertex oVertex2 = new MockVertex(); IGraph oGraph = new Graph(); oVertex1.ParentGraph = oGraph; oVertex2.ParentGraph = oGraph; IEdge oEdge = new MockEdge(oVertex1, oVertex2, false, false, 2); IVertex oVertexA, oVertexB; EdgeUtil.EdgeToVertices(oEdge, ClassName, MethodOrPropertyName, out oVertexA, out oVertexB); Assert.AreEqual(oVertex1, oVertexA); Assert.AreEqual(oVertex2, oVertexB); }
TestEdgeToVertices() { // Valid vertices. MockVertex oVertex1 = new MockVertex(); MockVertex oVertex2 = new MockVertex(); IGraph oGraph = new Graph(); oVertex1.ParentGraph = oGraph; oVertex2.ParentGraph = oGraph; IEdge oEdge = new MockEdge(oVertex1, oVertex2, false, false, 2); IVertex oVertexA, oVertexB; EdgeUtil.EdgeToVertices(oEdge, ClassName, MethodOrPropertyName, out oVertexA, out oVertexB); Assert.AreEqual(oVertex1, oVertexA); Assert.AreEqual(oVertex2, oVertexB); }
TestEdgeToVerticesBad8() { // Vertices not part of the same graph. try { MockVertex oVertex1 = new MockVertex(); MockVertex oVertex2 = new MockVertex(); IGraph oGraph1 = new Graph(GraphDirectedness.Mixed); IGraph oGraph2 = new Graph(GraphDirectedness.Mixed); oVertex1.ParentGraph = oGraph1; oVertex2.ParentGraph = oGraph2; IEdge oEdge = new MockEdge(oVertex1, oVertex2, false, false, 2); IVertex oVertexA, oVertexB; EdgeUtil.EdgeToVertices(oEdge, ClassName, MethodOrPropertyName, out oVertexA, out oVertexB); } catch (ApplicationException oApplicationException) { Assert.AreEqual( "TheClass.TheMethodOrProperty: The edge connects vertices not" + " in the same graph." , oApplicationException.Message ); throw oApplicationException; } }
TestAddBad4() { // Edge.Vertices contains 1 vertex only. try { IEdge oEdge = new MockEdge(null, null, false, false, 1); m_oEdgeCollection.Add(oEdge); } catch (ArgumentException oArgumentException) { Assert.AreEqual( "Smrf.NodeXL.Core." + "EdgeCollection.Add: The edge is invalid.\r\n" + "Parameter name: edge" , oArgumentException.Message ); Assert.IsNotNull(oArgumentException.InnerException); Assert.AreEqual( "Smrf.NodeXL.Core." + "EdgeCollection.Add: The edge does not connect two vertices." , oArgumentException.InnerException.Message ); throw oArgumentException; } }
TestEdgeToVerticesBad5() { // Second vertex is null. try { IEdge oEdge = new MockEdge( new MockVertex(), null, false, false, 2); IVertex oVertexA, oVertexB; EdgeUtil.EdgeToVertices(oEdge, ClassName, MethodOrPropertyName, out oVertexA, out oVertexB); } catch (ApplicationException oApplicationException) { Assert.AreEqual( "TheClass.TheMethodOrProperty: The edge's second vertex is" + " null." , oApplicationException.Message ); throw oApplicationException; } }
TestEdgeToVerticesBad3() { // Edge.Vertices contains 1 vertex only. try { IEdge oEdge = new MockEdge(null, null, false, false, 1); IVertex oVertexA, oVertexB; EdgeUtil.EdgeToVertices(oEdge, ClassName, MethodOrPropertyName, out oVertexA, out oVertexB); } catch (ApplicationException oApplicationException) { Assert.AreEqual( "TheClass.TheMethodOrProperty: The edge does not connect two" + " vertices." , oApplicationException.Message ); throw oApplicationException; } }
TestEdgeToVerticesBad() { // Null Edge.Vertices. try { IEdge oEdge = new MockEdge(null, null, false, true, 0); IVertex oVertexA, oVertexB; EdgeUtil.EdgeToVertices(oEdge, ClassName, MethodOrPropertyName, out oVertexA, out oVertexB); } catch (ApplicationException ApplicationException) { Assert.AreEqual( "TheClass.TheMethodOrProperty: The edge's Vertices property is" + " null." , ApplicationException.Message ); throw ApplicationException; } }
TestAddBad12() { // Directedness is wrong. try { InitializeGraph(GraphDirectedness.Undirected); IVertex [] aoVertices = AddVertices(2); IEdge oEdge = new MockEdge( aoVertices[0], aoVertices[1], true, false, 2); m_oEdgeCollection.Add(oEdge); } catch (ArgumentException oArgumentException) { Assert.AreEqual( "Smrf.NodeXL.Core." + "EdgeCollection.Add: A directed edge can't be added to an" + " undirected graph.\r\n" + "Parameter name: edge" , oArgumentException.Message ); throw oArgumentException; } }
TestAddBad10() { // Second vertex is of wrong type. try { IVertex [] aoVertices = AddVertices(1); MockVertex oWrongTypeVertex = new MockVertex(); oWrongTypeVertex.ParentGraph = m_oGraph; IEdge oEdge = new MockEdge( aoVertices[0], oWrongTypeVertex, false, false, 2); m_oEdgeCollection.Add(oEdge); } catch (ArgumentException oArgumentException) { Assert.AreEqual( "Smrf.NodeXL.Core." + "EdgeCollection.Add: The edge is invalid.\r\n" + "Parameter name: edge" , oArgumentException.Message ); Assert.IsNotNull(oArgumentException.InnerException); Assert.AreEqual( "Smrf.NodeXL.Core." + "EdgeCollection.Add: A vertex is not of type Vertex. The" + " type is Smrf.NodeXL" + ".UnitTests.MockVertex." , oArgumentException.InnerException.Message ); throw oArgumentException; } }
TestAddBad8() { // Second vertex not in graph. try { IVertex [] aoVertices = AddVertices(1); IVertex oNonContainedVertex = new Vertex(); IEdge oEdge = new MockEdge( aoVertices[0], oNonContainedVertex, false, false, 2); m_oEdgeCollection.Add(oEdge); } catch (ArgumentException oArgumentException) { Assert.AreEqual( "Smrf.NodeXL.Core." + "EdgeCollection.Add: The edge is invalid.\r\n" + "Parameter name: edge" , oArgumentException.Message ); Assert.IsNotNull(oArgumentException.InnerException); Assert.AreEqual( "Smrf.NodeXL.Core." + "EdgeCollection.Add: The edge's second vertex does not" + " belong to a graph." , oArgumentException.InnerException.Message ); throw oArgumentException; } }
TestAddBad6() { // Second vertex is null. try { IVertex [] aoVertices = AddVertices(1); IEdge oEdge = new MockEdge(aoVertices[0], null, false, false, 2); m_oEdgeCollection.Add(oEdge); } catch (ArgumentException oArgumentException) { Assert.AreEqual( "Smrf.NodeXL.Core." + "EdgeCollection.Add: The edge is invalid.\r\n" + "Parameter name: edge" , oArgumentException.Message ); Assert.IsNotNull(oArgumentException.InnerException); Assert.AreEqual( "Smrf.NodeXL.Core." + "EdgeCollection.Add: The edge's second vertex is null." , oArgumentException.InnerException.Message ); throw oArgumentException; } }
TestEdgeToVerticesBad7() { // Second vertex has no parent. try { MockVertex oVertex1 = new MockVertex(); MockVertex oVertex2 = new MockVertex(); IGraph oGraph = new Graph(); oVertex1.ParentGraph = oGraph; // oVertex2.ParentGraph = oGraph; IEdge oEdge = new MockEdge(oVertex1, oVertex2, false, false, 2); IVertex oVertexA, oVertexB; EdgeUtil.EdgeToVertices(oEdge, ClassName, MethodOrPropertyName, out oVertexA, out oVertexB); } catch (ApplicationException oApplicationException) { Assert.AreEqual( "TheClass.TheMethodOrProperty: The edge's second vertex does" + " not belong to a graph." , oApplicationException.Message ); throw oApplicationException; } }
TestAddBad2() { // Null Edge.Vertices. try { IEdge oEdge = new MockEdge(null, null, false, true, 0); m_oEdgeCollection.Add(oEdge); } catch (ArgumentException oArgumentException) { Assert.AreEqual( "Smrf.NodeXL.Core." + "EdgeCollection.Add: The edge is invalid.\r\n" + "Parameter name: edge" , oArgumentException.Message ); Assert.IsNotNull(oArgumentException.InnerException); Assert.AreEqual( "Smrf.NodeXL.Core." + "EdgeCollection.Add: The edge's Vertices property is null." , oArgumentException.InnerException.Message ); throw oArgumentException; } }