Implements IVertex for testing.
Inheritance: IVertex
Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
        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;
            }
        }
Beispiel #3
0
        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;
        }
    }
    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;
        }
    }
    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;
        }
    }
    TestAdd4_Bad5()
    {
        // First vertex is of wrong type.

        try
        {
            InitializeGraph(GraphDirectedness.Undirected);

            IVertex [] aoVertices = AddVertices(1);

            MockVertex oWrongTypeVertex = new MockVertex();

            oWrongTypeVertex.ParentGraph = m_oGraph;

            m_oEdgeCollection.Add( oWrongTypeVertex, aoVertices[0] );
        }
        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;
        }
    }