Exemplo n.º 1
0
        public void Should_Be_Able_To_Create_Vertex_With_MetaProperties()
        {
            var g        = DseGraph.Traversal(Session);
            var guid     = Guid.NewGuid();
            var metaProp = new MetaProp {
                SubProp = "Dragonglass", SubProp2 = "Valyrian steel"
            };

            g.AddV("meta_v")
            .Property("pk", guid)
            .Property("meta_prop", metaProp)
            .Next();

            StatementCoreIntegrationTest.VerifyMetaProperties(Session, g, guid, metaProp);
            g.V().HasLabel("meta_v").Drop().Next();
        }
Exemplo n.º 2
0
        public void Should_Be_Able_To_Create_Vertex_With_MetaProperties()
        {
            Session.UserDefinedTypes.Define(UdtMap.For <MetaProp>("meta_prop_type", GraphName)
                                            .Map(u => u.SubProp, "sub_prop").Map(u => u.SubProp2, "sub_prop2"));
            var g        = DseGraph.Traversal(Session);
            var guid     = Guid.NewGuid();
            var metaProp = new MetaProp {
                SubProp = "Qyburn's scorpion", SubProp2 = "Another dragon"
            };
            var stmt = DseGraph.StatementFromTraversal(g.AddV("meta_v")
                                                       .Property("pk", guid)
                                                       .Property("meta_prop", metaProp));

            Session.ExecuteGraph(stmt);
            StatementCoreIntegrationTest.VerifyMetaProperties(Session, g, guid, metaProp);
            var dropstmt = DseGraph.StatementFromTraversal(g.V().HasLabel("meta_v").Drop());

            Session.ExecuteGraph(dropstmt);
        }
Exemplo n.º 3
0
        public static void VerifyMetaProperties(ISession session, GraphTraversalSource g, Guid pk, MetaProp metaProp)
        {
            var stmt    = DseGraph.StatementFromTraversal(g.V().HasLabel("meta_v"));
            var walkers = session.ExecuteGraph(stmt);
            var result  = walkers.FirstOrDefault();

            Assert.IsNotNull(result);
            var nightKing = result.ToVertex();

            TestHelper.FillVertexProperties(session, nightKing);
            Assert.AreEqual("meta_v", nightKing.Label);
            var dbPk       = nightKing.GetProperty("pk").Value.To <Guid>();
            var dbMetaProp = nightKing.GetProperty("meta_prop").Value.To <MetaProp>();

            Assert.AreEqual(pk, dbPk);
            Assert.AreEqual(metaProp.SubProp, dbMetaProp.SubProp);
            Assert.AreEqual(metaProp.SubProp2, dbMetaProp.SubProp2);

            var dbMetaPropDict = nightKing.GetProperty("meta_prop").Value.To <IDictionary <string, string> >();

            Assert.AreEqual(metaProp.SubProp, dbMetaPropDict["sub_prop"]);
            Assert.AreEqual(metaProp.SubProp2, dbMetaPropDict["sub_prop2"]);
        }