Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
0
        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;
            }
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public void TestAddBad9()
        {
            // First vertex is of wrong type.

            try
            {
            IVertex [] aoVertices = AddVertices(1);

            MockVertex oWrongTypeVertex = new MockVertex();

            oWrongTypeVertex.ParentGraph = m_oGraph;

            IEdge oEdge = new MockEdge(
                oWrongTypeVertex, aoVertices[0], false, false, 2);

            m_oEdgeCollection.Add(oEdge);
            }
            catch (ArgumentException oArgumentException)
            {
            Assert.AreEqual(
                "Microsoft.NodeXL.Core."
                + "EdgeCollection.Add: The edge is invalid.\r\n"
                + "Parameter name: edge"
                ,
                oArgumentException.Message
                );

            Assert.IsNotNull(oArgumentException.InnerException);

            Assert.AreEqual(

                "Microsoft.NodeXL.Core."
                + "EdgeCollection.Add: A vertex is not of type Vertex.  The"
                + " type is Microsoft.NodeXL"
                + ".UnitTests.MockVertex."
                ,
                oArgumentException.InnerException.Message
                );

            throw oArgumentException;
            }
        }
Ejemplo n.º 8
0
        public void 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(
                "Microsoft.NodeXL.Core."
                + "EdgeCollection.Add: The edge is invalid.\r\n"
                + "Parameter name: edge"
                ,
                oArgumentException.Message
                );

            Assert.IsNotNull(oArgumentException.InnerException);

            Assert.AreEqual(

                "Microsoft.NodeXL.Core."
                + "EdgeCollection.Add: The edge's second vertex does not"
                + " belong to a graph."
                ,
                oArgumentException.InnerException.Message
                );

            throw oArgumentException;
            }
        }
Ejemplo n.º 9
0
        public void 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(
                "Microsoft.NodeXL.Core."
                + "EdgeCollection.Add: The edge is invalid.\r\n"
                + "Parameter name: edge"
                ,
                oArgumentException.Message
                );

            Assert.IsNotNull(oArgumentException.InnerException);

            Assert.AreEqual(

                "Microsoft.NodeXL.Core."
                + "EdgeCollection.Add: The edge's second vertex is null."
                ,
                oArgumentException.InnerException.Message
                );

            throw oArgumentException;
            }
        }
Ejemplo n.º 10
0
        public void 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(
                "Microsoft.NodeXL.Core."
                + "EdgeCollection.Add: The edge is invalid.\r\n"
                + "Parameter name: edge"
                ,
                oArgumentException.Message
                );

            Assert.IsNotNull(oArgumentException.InnerException);

            Assert.AreEqual(

                "Microsoft.NodeXL.Core."
                + "EdgeCollection.Add: The edge does not connect two vertices."
                ,
                oArgumentException.InnerException.Message
                );

            throw oArgumentException;
            }
        }
Ejemplo n.º 11
0
        public void TestAddBad2()
        {
            // Null Edge.Vertices.

            try
            {
            IEdge oEdge = new MockEdge(null, null, false, true, 0);

            m_oEdgeCollection.Add(oEdge);
            }
            catch (ArgumentException oArgumentException)
            {
            Assert.AreEqual(
                "Microsoft.NodeXL.Core."
                + "EdgeCollection.Add: The edge is invalid.\r\n"
                + "Parameter name: edge"
                ,
                oArgumentException.Message
                );

            Assert.IsNotNull(oArgumentException.InnerException);

            Assert.AreEqual(

                "Microsoft.NodeXL.Core."
                + "EdgeCollection.Add: The edge's Vertices property is null."
                ,
                oArgumentException.InnerException.Message
                );

            throw oArgumentException;
            }
        }
Ejemplo n.º 12
0
        public void 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(

                "Microsoft.NodeXL.Core."
                + "EdgeCollection.Add: A directed edge can't be added to an"
                + " undirected graph.\r\n"
                + "Parameter name: edge"
                ,
                oArgumentException.Message
                );

            throw oArgumentException;
            }
        }