Esempio n. 1
0
        public void SampleGraph_PathsNotLonger2()
        {
            var g = GenerateSampleGraph();

            var somePathFinder = new PathFinder("A", "E", 2, g);

            var toCheck = new List <Path>(somePathFinder.GetAllPaths());

            var idA    = g.GetIdOfVertex("A");
            var idB    = g.GetIdOfVertex("B");
            var idC    = g.GetIdOfVertex("C");
            var idD    = g.GetIdOfVertex("D");
            var idE    = g.GetIdOfVertex("E");
            var answer = new List <Path>
            {
                new Path(new List <Edge> {
                    new Edge(idA, idD, 2), new Edge(idD, idE, 8)
                }),
                new Path(new List <Edge> {
                    new Edge(idA, idC, 1), new Edge(idC, idE, 6)
                }),
                new Path(new List <Edge> {
                    new Edge(idA, idB, 0), new Edge(idB, idE, 5)
                })
            };

            var comp = new CompareSomething();

            toCheck.Sort(comp.ComparePaths);
            answer.Sort(comp.ComparePaths);

            var flag = comp.CompareListPaths(answer, toCheck) == 0;

            Assert.Equal(true, flag);
        }
Esempio n. 2
0
        public void Added2EdgesForOneVertex_ReturnBoth()
        {
            var vertex1 = new VertexOfTable("sample", new List <string>());
            var vertex2 = new VertexOfTable("sample1", new List <string>());
            var graph   = new Graph();

            graph.AddVertexIfNonExist(vertex1);
            graph.AddVertexIfNonExist(vertex2);
            graph.AddEdgeIfVertexExist("sample", "sample1", 0);
            graph.AddEdgeIfVertexExist("sample", "sample1", 1);
            var id1        = graph.GetIdOfVertex("sample");
            var id2        = graph.GetIdOfVertex("sample1");
            var outputList = new List <Edge>(graph.GetEdgesByVertexId(graph.GetIdOfVertex("sample")));
            var goodList   = new List <Edge> {
                new Edge(id1, id2, 0), new Edge(id1, id2, 1)
            };
            var comp = new CompareSomething();

            goodList.Sort(comp.CompareEdges);
            outputList.Sort(comp.CompareEdges);
            var flag = comp.CompareListEdges(outputList, goodList) == 0;

            Assert.Equal(true, flag);
        }