public void Get_T_Should_Throw_For_Not_Supported_Types()
        {
            const string json = "{\"result\": {\"something\": \"123\" }}";

            GraphNodeGraphSON1Tests.TestGetThrows <IntPtr, NotSupportedException>(json, "something");
            GraphNodeGraphSON1Tests.TestGetThrows <UIntPtr, NotSupportedException>(json, "something");
            GraphNodeGraphSON1Tests.TestGetThrows <StringBuilder, NotSupportedException>(json, "something");
        }
 public void Get_T_Should_Allow_Geometry_Types()
 {
     GraphNodeGraphSON1Tests.TestGet("{\"result\": {\"something\": \"POINT (1.0 2.0)\" }}", "something", new Point(1, 2));
     GraphNodeGraphSON1Tests.TestGet("{\"result\": {\"something\": \"LINESTRING (1 2, 3 4.1234)\" }}", "something",
                                     new LineString(new Point(1, 2), new Point(3, 4.1234)));
     GraphNodeGraphSON1Tests.TestGet("{\"result\": {\"something\": \"POLYGON ((1 3, 3 1, 3 6, 1 3))\" }}", "something",
                                     new Polygon(new Point(1, 3), new Point(3, 1), new Point(3, 6), new Point(1, 3)));
 }
        public void To_T_Should_Throw_For_Not_Supported_Types()
        {
            const string json = "{\"result\": \"123\"}";

            GraphNodeGraphSON1Tests.TestToThrows <IntPtr, NotSupportedException>(json);
            GraphNodeGraphSON1Tests.TestToThrows <UIntPtr, NotSupportedException>(json);
            GraphNodeGraphSON1Tests.TestToThrows <StringBuilder, NotSupportedException>(json);
        }
        public void ToVertex_Should_Not_Throw_When_The_Properties_Is_Not_Present()
        {
            var vertex = GraphNodeGraphSON1Tests.GetGraphNode(
                "{" +
                "\"id\":{\"member_id\":0,\"community_id\":586910,\"~label\":\"vertex\",\"group_id\":2}," +
                "\"label\":\"vertex1\"," +
                "\"type\":\"vertex\"" +
                "}").ToVertex();

            Assert.AreEqual("vertex1", vertex.Label);
            Assert.NotNull(vertex.Id);
        }
 public void ToVertex_Should_Throw_When_Required_Attributes_Are_Not_Present()
 {
     Assert.Throws <InvalidOperationException>(() => GraphNodeGraphSON1Tests.GetGraphNode(
                                                   "{" +
                                                   "\"label\":\"vertex1\"," +
                                                   "\"type\":\"vertex\"" +
                                                   "}").ToVertex());
     Assert.Throws <InvalidOperationException>(() => GraphNodeGraphSON1Tests.GetGraphNode(
                                                   "{" +
                                                   "\"id\":{\"member_id\":0,\"community_id\":586910,\"~label\":\"vertex\",\"group_id\":2}," +
                                                   "\"type\":\"vertex\"" +
                                                   "}").ToVertex());
 }
 public void To_T_Should_Allow_Serializable_Types()
 {
     GraphNodeGraphSON1Tests.TestTo("{\"result\": 2.2}", 2.2M);
     GraphNodeGraphSON1Tests.TestTo("{\"result\": 2.2}", 2.2D);
     GraphNodeGraphSON1Tests.TestTo("{\"result\": 2.2}", 2.2F);
     GraphNodeGraphSON1Tests.TestTo("{\"result\": 22}", 22);
     GraphNodeGraphSON1Tests.TestTo("{\"result\": 22}", (int?)22);
     GraphNodeGraphSON1Tests.TestTo("{\"result\": 22}", 22L);
     GraphNodeGraphSON1Tests.TestTo("{\"result\": 22}", BigInteger.Parse("22"));
     GraphNodeGraphSON1Tests.TestTo("{\"result\": 22}", "22");
     GraphNodeGraphSON1Tests.TestTo("{\"result\": \"92d4a960-1cf3-11e6-9417-bd9ef43c1c95\"}", Guid.Parse("92d4a960-1cf3-11e6-9417-bd9ef43c1c95"));
     GraphNodeGraphSON1Tests.TestTo("{\"result\": \"92d4a960-1cf3-11e6-9417-bd9ef43c1c95\"}", (Guid?)Guid.Parse("92d4a960-1cf3-11e6-9417-bd9ef43c1c95"));
     GraphNodeGraphSON1Tests.TestTo("{\"result\": \"92d4a960-1cf3-11e6-9417-bd9ef43c1c95\"}", (TimeUuid)Guid.Parse("92d4a960-1cf3-11e6-9417-bd9ef43c1c95"));
 }
        public void ToEdge_Should_Not_Throw_When_The_Properties_Is_Not_Present()
        {
            var edge = GraphNodeGraphSON1Tests.GetGraphNode("{" +
                                                            "\"id\":{" +
                                                            "\"out_vertex\":{\"member_id\":0,\"community_id\":680148,\"~label\":\"vertex\",\"group_id\":3}," +
                                                            "\"local_id\":\"4e78f871-c5c8-11e5-a449-130aecf8e504\",\"in_vertex\":{\"member_id\":0,\"community_id\":680148,\"~label\":\"vertex\",\"group_id\":5},\"~type\":\"knows\"}," +
                                                            "\"label\":\"knows\"," +
                                                            "\"type\":\"edge\"," +
                                                            "\"inVLabel\":\"in-vertex\"" +
                                                            "}").ToEdge();

            Assert.AreEqual("knows", edge.Label);
            Assert.AreEqual("in-vertex", edge.InVLabel);
            Assert.Null(edge.OutVLabel);
        }
 public void Get_T_Should_Allow_Serializable_Types()
 {
     GraphNodeGraphSON1Tests.TestGet("{\"result\": {\"something\": 1.2 }}", "something", 1.2M);
     GraphNodeGraphSON1Tests.TestGet("{\"result\": {\"something\": 12 }}", "something", 12);
     GraphNodeGraphSON1Tests.TestGet("{\"result\": {\"something\": 12 }}", "something", 12L);
     GraphNodeGraphSON1Tests.TestGet("{\"result\": {\"something\": 1.2 }}", "something", 1.2D);
     GraphNodeGraphSON1Tests.TestGet("{\"result\": {\"something\": 1.2 }}", "something", 1.2F);
     GraphNodeGraphSON1Tests.TestGet("{\"result\": {\"something\": 1.2 }}", "something", "1.2");
     GraphNodeGraphSON1Tests.TestGet("{\"result\": {\"something\": \"123e4567-e89b-12d3-a456-426655440000\" }}", "something",
                                     Guid.Parse("123e4567-e89b-12d3-a456-426655440000"));
     GraphNodeGraphSON1Tests.TestGet("{\"result\": {\"something\": 12 }}", "something", BigInteger.Parse("12"));
     GraphNodeGraphSON1Tests.TestGet("{\"result\": {\"something\": \"92d4a960-1cf3-11e6-9417-bd9ef43c1c95\" }}", "something",
                                     (TimeUuid)Guid.Parse("92d4a960-1cf3-11e6-9417-bd9ef43c1c95"));
     GraphNodeGraphSON1Tests.TestGet("{\"result\": {\"something\": [1, 2, 3] }}", "something", new[] { 1, 2, 3 });
     GraphNodeGraphSON1Tests.TestGet <IEnumerable <int> >("{\"result\": {\"something\": [1, 2, 3] }}", "something", new[] { 1, 2, 3 });
 }
        public void ToEdge_Should_Throw_When_Required_Attributes_Are_Not_Present()
        {
            Assert.Throws <InvalidOperationException>(() => GraphNodeGraphSON1Tests.GetGraphNode(
                                                          "{" +
                                                          "\"label\":\"knows\"," +
                                                          "\"type\":\"edge\"," +
                                                          "\"inVLabel\":\"in-vertex\"" +
                                                          "}").ToEdge());

            Assert.Throws <InvalidOperationException>(() => GraphNodeGraphSON1Tests.GetGraphNode(
                                                          "{" +
                                                          "\"id\":{" +
                                                          "\"out_vertex\":{\"member_id\":0,\"community_id\":680148,\"~label\":\"vertex\",\"group_id\":3}," +
                                                          "\"local_id\":\"4e78f871-c5c8-11e5-a449-130aecf8e504\",\"in_vertex\":{\"member_id\":0,\"community_id\":680148,\"~label\":\"vertex\",\"group_id\":5},\"~type\":\"knows\"}," +
                                                          "\"type\":\"edge\"," +
                                                          "\"inVLabel\":\"in-vertex\"" +
                                                          "}").ToEdge());
        }