예제 #1
0
        public void GetAllPathsExampleFromAtoB()
        {
            IEnumerable <GraphPath> resultPaths   = this.routesCalculatorService.GetAllNonDirectPaths(1, 2);
            IList <GraphPath>       expectedPaths = this.getExpectedPathsFromAtoB();

            // assertions
            Assert.AreEqual(resultPaths.Count(), expectedPaths.Count, "Number of calculated routes does not match.");

            foreach (GraphPath expectedPath in expectedPaths)
            {
                GraphPath resultPath = resultPaths.Where(x => x.PointIds.SequenceEqual(expectedPath.PointIds))
                                       .Single();

                Assert.IsNotNull(resultPath, String.Format("Missing route {0}", resultPath.ToString()));
                Assert.AreEqual(expectedPath.Cost, resultPath.Cost, String.Format("Route Cost does not match for route {0}", resultPath.ToString()));
                Assert.AreEqual(expectedPath.Minutes, resultPath.Minutes, String.Format("Route Time does not match for route {0}", resultPath.ToString()));
            }
        }
예제 #2
0
        public async Task GraphPathTests()
        {
            var store = await StoreBuilder.New().CreateAsync();

            await store.Schemas.New <TestDomainDefinition>().CreateAsync();

            var domain = await store.DomainModels.New().CreateAsync("Test");

            var start = new Identity("test", "1");
            var p     = new GraphPath(domain, start);
            var p2    = new GraphPath(domain, start);

            Assert.Equal(0, p.Length);
            Assert.Equal(1, p.Elements.Count());
            Assert.Equal(0, p.Relationships.Count());
            Assert.Equal(start, p.StartElement);
            Assert.Equal(start, p.EndElement);

            var end  = new Identity("test", "3");
            var edge = new EdgeInfo(new Identity("test", "2"), new Identity("test", "Has"), end);

            p  = p.Create(end, edge);
            p2 = p2.Create(end, edge);

            Assert.Equal(1, p.Length);
            Assert.Equal(2, p.Elements.Count());
            Assert.Equal(1, p.Relationships.Count());
            Assert.Equal(start, p.StartElement);
            Assert.Equal(end, p.EndElement);


            end  = new Identity("test", "5");
            edge = new EdgeInfo(new Identity("test", "4"), new Identity("test", "Has"), end);

            p  = p.Create(end, edge);
            p2 = p2.Create(end, edge);

            Assert.Equal(2, p.Length);
            Assert.Equal(3, p.Elements.Count());
            Assert.Equal(2, p.Relationships.Count());
            Assert.Equal(start, p.StartElement);
            Assert.Equal(end, p.EndElement);

            Assert.Equal(p, p2);

            Assert.Equal("[test:1] -- test:has --> [test:3] -- test:has --> [test:5]", p.ToString());
        }