Esempio n. 1
0
        public void AddEdge_Throws_Ex_If_Edge_Is_Null()
        {
            var net =new BasicAdjList(Guid.NewGuid());
            BasicNode node0 = new BasicNode(net);

            BasicEdge edge0 = null;
            var ex = Assert.Throws<ArgumentNullException>(() => node0.AddEdge(edge0));
        }
Esempio n. 2
0
        public void AddEdge_Throws_Ex_If_Edge_Is_Invalid_Type()
        {
            var net =new BasicAdjList(Guid.NewGuid());
            BasicNode node0 = new BasicNode(net);

            DummyBasicEdge edge0 = new DummyBasicEdge();
            var ex = Assert.Throws<ArgumentException>(() => node0.AddEdge(edge0));
        }
Esempio n. 3
0
        public void AddEdge_IncrementsDegree_ForSelfLoop()
        {
            var net =new BasicAdjList(Guid.NewGuid());
            BasicNode node0 = new BasicNode(net);
            BasicNode node1 = new BasicNode(net);

            BasicEdge edge0 = new BasicEdge(net, node0, node0);

            int degree = node0.Degree;
            Assert.Equal(0, degree);
            node0.AddEdge(edge0);
            degree = node0.Degree;
            Assert.Equal(2, degree);
        }
Esempio n. 4
0
        public void RemoveEdge_DecrementsDegree()
        {
            var net =new BasicAdjList(Guid.NewGuid());
            BasicNode node0 = new BasicNode(net);
            BasicNode node1 = new BasicNode(net);

            BasicEdge edge0 = new BasicEdge(net, node0, node1);

            node0.AddEdge(edge0);
            Assert.Equal(1, node0.Degree);

            node0.RemoveEdge(edge0);
            Assert.Equal(0, node0.Degree);
        }