コード例 #1
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());
        }