public void ShouldCreateEdgeFromOEdge()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GLOBAL_TEST_DATABASE_ALIAS))
                {
                    OVertex vertex1 = database
                                      .Create.Vertex <OVertex>()
                                      .Run();

                    OVertex vertex2 = database
                                      .Create.Vertex <OVertex>()
                                      .Run();

                    OEdge edge = new OEdge();
                    edge.SetField("Foo", "foo string value");
                    edge.SetField("Bar", 12345);

                    OEdge createdEdge = database
                                        .Create.Edge(edge)
                                        .From(vertex1)
                                        .To(vertex2)
                                        .Run();

                    Assert.IsTrue(!string.IsNullOrEmpty(createdEdge.ORID.ToString()));
                    Assert.AreEqual(createdEdge.Label, "E");
                    Assert.AreEqual(createdEdge.OClassName, "E");
                    Assert.AreEqual(createdEdge.InV, vertex2.ORID);
                    Assert.AreEqual(createdEdge.OutV, vertex1.ORID);
                    Assert.AreEqual(createdEdge.GetField <string>("Foo"), edge.GetField <string>("Foo"));
                    Assert.AreEqual(createdEdge.GetField <int>("Bar"), edge.GetField <int>("Bar"));
                }
            }
        }
        public void ShouldCreateEdgeFromOEdge()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    OVertex vertex1 = database
                                      .Create.Vertex <OVertex>()
                                      .Run();

                    OVertex vertex2 = database
                                      .Create.Vertex <OVertex>()
                                      .Run();

                    OEdge edge = new OEdge();
                    edge.SetField("Foo", "foo string value");
                    edge.SetField("Bar", 12345);

                    OEdge createdEdge = database
                                        .Create.Edge(edge)
                                        .From(vertex1)
                                        .To(vertex2)
                                        .Run();

                    Assert.NotNull(createdEdge.ORID);
                    Assert.Equal("E", createdEdge.Label);
                    Assert.Equal("E", createdEdge.OClassName);
                    Assert.Equal(vertex2.ORID, createdEdge.InV);
                    Assert.Equal(vertex1.ORID, createdEdge.OutV);
                    Assert.Equal(edge.GetField <string>("Foo"), createdEdge.GetField <string>("Foo"));
                    Assert.Equal(edge.GetField <int>("Bar"), createdEdge.GetField <int>("Bar"));
                }
            }
        }
        public void ShouldCreateEdgeFromToSet()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GLOBAL_TEST_DATABASE_ALIAS))
                {
                    // prerequisites
                    database
                    .Create.Class("TestEdgeClass")
                    .Extends <OEdge>()
                    .Run();

                    OVertex vertex1 = database
                                      .Create.Vertex <OVertex>()
                                      .Run();

                    OVertex vertex2 = database
                                      .Create.Vertex <OVertex>()
                                      .Run();

                    OEdge createdEdge = database
                                        .Create.Edge("TestEdgeClass")
                                        .From(vertex1.ORID)
                                        .To(vertex2.ORID)
                                        .Set("foo", "foo string value")
                                        .Set("bar", 12345)
                                        .Run();

                    Assert.IsTrue(!string.IsNullOrEmpty(createdEdge.ORID.ToString()));
                    Assert.AreEqual(createdEdge.Label, "TestEdgeClass");
                    Assert.AreEqual(createdEdge.OClassName, "TestEdgeClass");
                    Assert.AreEqual(createdEdge.InV, vertex2.ORID);
                    Assert.AreEqual(createdEdge.OutV, vertex1.ORID);
                    Assert.AreEqual(createdEdge.GetField <string>("foo"), "foo string value");
                    Assert.AreEqual(createdEdge.GetField <int>("bar"), 12345);
                }
            }
        }
        public void ShouldCreateEdgeFromToSet()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                    .Create.Class("TestEdgeClass")
                    .Extends <OEdge>()
                    .Run();

                    OVertex vertex1 = database
                                      .Create.Vertex <OVertex>()
                                      .Run();

                    OVertex vertex2 = database
                                      .Create.Vertex <OVertex>()
                                      .Run();

                    OEdge createdEdge = database
                                        .Create.Edge("TestEdgeClass")
                                        .From(vertex1.ORID)
                                        .To(vertex2.ORID)
                                        .Set("foo", "foo string value")
                                        .Set("bar", 12345)
                                        .Run();

                    Assert.NotNull(createdEdge.ORID);
                    Assert.Equal("TestEdgeClass", createdEdge.Label);
                    Assert.Equal("TestEdgeClass", createdEdge.OClassName);
                    Assert.Equal(vertex2.ORID, createdEdge.InV);
                    Assert.Equal(vertex1.ORID, createdEdge.OutV);
                    Assert.Equal("foo string value", createdEdge.GetField <string>("foo"));
                    Assert.Equal(12345, createdEdge.GetField <int>("bar"));
                }
            }
        }
Beispiel #5
0
        public void ShouldCreateVerticesWithEdge()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    OVertex vertex1 = database
                                      .Create.Vertex <OVertex>()
                                      .Set("Foo", "foo string value1")
                                      .Set("Bar", 12345)
                                      .Run <OVertex>();

                    Assert.True(!string.IsNullOrEmpty(vertex1.ORID.ToString()));
                    Assert.Equal("V", vertex1.OClassName);
                    Assert.Equal("foo string value1", vertex1.GetField <string>("Foo"));
                    Assert.Equal(12345, vertex1.GetField <int>("Bar"));

                    OVertex vertex2 = database
                                      .Create.Vertex <OVertex>()
                                      .Set("Foo", "foo string value2")
                                      .Set("Bar", 54321)
                                      .Run <OVertex>();

                    Assert.True(!string.IsNullOrEmpty(vertex2.ORID.ToString()));
                    Assert.Equal("V", vertex2.OClassName);
                    Assert.Equal("foo string value2", vertex2.GetField <string>("Foo"));
                    Assert.Equal(54321, vertex2.GetField <int>("Bar"));

                    OVertex vertex3 = database
                                      .Create.Vertex <OVertex>()
                                      .Set("Foo", "foo string value3")
                                      .Set("Bar", 347899)
                                      .Run <OVertex>();

                    Assert.True(!string.IsNullOrEmpty(vertex3.ORID.ToString()));
                    Assert.Equal("V", vertex3.OClassName);
                    Assert.Equal("foo string value3", vertex3.GetField <string>("Foo"));
                    Assert.Equal(347899, vertex3.GetField <int>("Bar"));

                    OEdge edge1 = database
                                  .Create.Edge <OEdge>()
                                  .From(vertex1)
                                  .To(vertex2)
                                  .Set("Foo", "foo string value3")
                                  .Set("Bar", 123)
                                  .Run <OEdge>();

                    Assert.True(!string.IsNullOrEmpty(edge1.ORID.ToString()));
                    Assert.Equal("E", edge1.Label);
                    Assert.Equal("E", edge1.OClassName);
                    Assert.Equal(vertex2.ORID, edge1.InV);
                    Assert.Equal(vertex1.ORID, edge1.OutV);
                    Assert.Equal("foo string value3", edge1.GetField <string>("Foo"));
                    Assert.Equal(123, edge1.GetField <int>("Bar"));

                    OEdge edge2 = database
                                  .Create.Edge <OEdge>()
                                  .From(vertex1)
                                  .To(vertex3)
                                  .Set("Foo", "foo string value4")
                                  .Set("Bar", 245)
                                  .Run <OEdge>();

                    Assert.True(!string.IsNullOrEmpty(edge2.ORID.ToString()));
                    Assert.Equal("E", edge2.Label);
                    Assert.Equal("E", edge2.OClassName);
                    Assert.Equal(vertex3.ORID, edge2.InV);
                    Assert.Equal(vertex1.ORID, edge2.OutV);
                    Assert.Equal("foo string value4", edge2.GetField <string>("Foo"));
                    Assert.Equal(245, edge2.GetField <int>("Bar"));

                    OVertex loadedVertex1 = database
                                            .Select()
                                            .From(vertex1)
                                            .ToList <OVertex>().First();

                    Assert.True(!string.IsNullOrEmpty(loadedVertex1.ORID.ToString()));
                    Assert.Equal("V", loadedVertex1.OClassName);
                    Assert.Equal(0, loadedVertex1.InE.Count);
                    Assert.Equal(2, loadedVertex1.OutE.Count);
                    Assert.True(loadedVertex1.OutE.Contains(edge1.ORID));
                    Assert.True(loadedVertex1.OutE.Contains(edge2.ORID));
                    Assert.Equal(vertex1.GetField <string>("Foo"), loadedVertex1.GetField <string>("Foo"));
                    Assert.Equal(vertex1.GetField <int>("Bar"), loadedVertex1.GetField <int>("Bar"));

                    OVertex loadedVertex2 = database
                                            .Select()
                                            .From(vertex2)
                                            .ToList <OVertex>().First();

                    Assert.True(!string.IsNullOrEmpty(loadedVertex2.ORID.ToString()));
                    Assert.Equal("V", loadedVertex2.OClassName);
                    Assert.Equal(0, loadedVertex2.OutE.Count);
                    Assert.Equal(1, loadedVertex2.InE.Count);
                    Assert.True(loadedVertex2.InE.Contains(edge1.ORID));
                    Assert.Equal(vertex2.GetField <string>("Foo"), loadedVertex2.GetField <string>("Foo"));
                    Assert.Equal(vertex2.GetField <int>("Bar"), loadedVertex2.GetField <int>("Bar"));
                }
            }
        }
        public void ShouldCreateVerticesWithEdge()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GLOBAL_TEST_DATABASE_ALIAS))
                {
                    OVertex vertex1 = database
                                      .Create.Vertex <OVertex>()
                                      .Set("Foo", "foo string value1")
                                      .Set("Bar", 12345)
                                      .Run <OVertex>();

                    Assert.IsTrue(!string.IsNullOrEmpty(vertex1.ORID.ToString()));
                    Assert.AreEqual(vertex1.OClassName, "V");
                    Assert.AreEqual(vertex1.GetField <string>("Foo"), "foo string value1");
                    Assert.AreEqual(vertex1.GetField <int>("Bar"), 12345);

                    OVertex vertex2 = database
                                      .Create.Vertex <OVertex>()
                                      .Set("Foo", "foo string value2")
                                      .Set("Bar", 54321)
                                      .Run <OVertex>();

                    Assert.IsTrue(!string.IsNullOrEmpty(vertex2.ORID.ToString()));
                    Assert.AreEqual(vertex2.OClassName, "V");
                    Assert.AreEqual(vertex2.GetField <string>("Foo"), "foo string value2");
                    Assert.AreEqual(vertex2.GetField <int>("Bar"), 54321);

                    OVertex vertex3 = database
                                      .Create.Vertex <OVertex>()
                                      .Set("Foo", "foo string value3")
                                      .Set("Bar", 347899)
                                      .Run <OVertex>();

                    Assert.IsTrue(!string.IsNullOrEmpty(vertex3.ORID.ToString()));
                    Assert.AreEqual(vertex3.OClassName, "V");
                    Assert.AreEqual(vertex3.GetField <string>("Foo"), "foo string value3");
                    Assert.AreEqual(vertex3.GetField <int>("Bar"), 347899);

                    OEdge edge1 = database
                                  .Create.Edge <OEdge>()
                                  .From(vertex1)
                                  .To(vertex2)
                                  .Set("Foo", "foo string value3")
                                  .Set("Bar", 123)
                                  .Run <OEdge>();

                    Assert.IsTrue(!string.IsNullOrEmpty(edge1.ORID.ToString()));
                    Assert.AreEqual(edge1.Label, "E");
                    Assert.AreEqual(edge1.OClassName, "E");
                    Assert.AreEqual(edge1.InV, vertex2.ORID);
                    Assert.AreEqual(edge1.OutV, vertex1.ORID);
                    Assert.AreEqual(edge1.GetField <string>("Foo"), "foo string value3");
                    Assert.AreEqual(edge1.GetField <int>("Bar"), 123);

                    OEdge edge2 = database
                                  .Create.Edge <OEdge>()
                                  .From(vertex1)
                                  .To(vertex3)
                                  .Set("Foo", "foo string value4")
                                  .Set("Bar", 245)
                                  .Run <OEdge>();

                    Assert.IsTrue(!string.IsNullOrEmpty(edge2.ORID.ToString()));
                    Assert.AreEqual(edge2.Label, "E");
                    Assert.AreEqual(edge2.OClassName, "E");
                    Assert.AreEqual(edge2.InV, vertex3.ORID);
                    Assert.AreEqual(edge2.OutV, vertex1.ORID);
                    Assert.AreEqual(edge2.GetField <string>("Foo"), "foo string value4");
                    Assert.AreEqual(edge2.GetField <int>("Bar"), 245);

                    OVertex loadedVertex1 = database
                                            .Select()
                                            .From(vertex1)
                                            .ToList <OVertex>().First();

                    Assert.IsTrue(!string.IsNullOrEmpty(loadedVertex1.ORID.ToString()));
                    Assert.AreEqual(loadedVertex1.OClassName, "V");
                    Assert.AreEqual(loadedVertex1.InE.Count, 0);
                    Assert.AreEqual(loadedVertex1.OutE.Count, 2);
                    Assert.IsTrue(loadedVertex1.OutE.Contains(edge1.ORID));
                    Assert.IsTrue(loadedVertex1.OutE.Contains(edge2.ORID));
                    Assert.AreEqual(loadedVertex1.GetField <string>("Foo"), vertex1.GetField <string>("Foo"));
                    Assert.AreEqual(loadedVertex1.GetField <int>("Bar"), vertex1.GetField <int>("Bar"));

                    OVertex loadedVertex2 = database
                                            .Select()
                                            .From(vertex2)
                                            .ToList <OVertex>().First();

                    Assert.IsTrue(!string.IsNullOrEmpty(loadedVertex2.ORID.ToString()));
                    Assert.AreEqual(loadedVertex2.OClassName, "V");
                    Assert.AreEqual(loadedVertex2.OutE.Count, 0);
                    Assert.AreEqual(loadedVertex2.InE.Count, 1);
                    Assert.IsTrue(loadedVertex2.InE.Contains(edge1.ORID));
                    Assert.AreEqual(loadedVertex2.GetField <string>("Foo"), vertex2.GetField <string>("Foo"));
                    Assert.AreEqual(loadedVertex2.GetField <int>("Bar"), vertex2.GetField <int>("Bar"));
                }
            }
        }