public void Read_GraphSonWithUnknownGeoshape_Throw()
        {
            const string graphSon =
                "{\"@type\":\"janusgraph:Geoshape\",\"@value\":{\"geometry\":{\"type\":\"Unknown\"}}}";
            var reader = JanusGraphSONReaderBuilder.Build().Create();

            Assert.Throws <InvalidOperationException>(() => reader.ToObject(JToken.Parse(graphSon)));
        }
Пример #2
0
        public void SerializeAndDeserialize_ValidRelationIdentifier_SameRelationIdentifier()
        {
            var relationIdentifier = new RelationIdentifier("someRelationId");
            var writer             = JanusGraphSONWriterBuilder.Build().Create();
            var reader             = JanusGraphSONReaderBuilder.Build().Create();

            var graphSon = writer.WriteObject(relationIdentifier);
            var readRelationIdentifier = reader.ToObject(JToken.Parse(graphSon));

            Assert.Equal(relationIdentifier, readRelationIdentifier);
        }
        public void SerializeAndDeserialize_ValidPoint_SamePoint()
        {
            var point  = Geoshape.Point(1.234, 9.87);
            var writer = JanusGraphSONWriterBuilder.Build().Create();
            var reader = JanusGraphSONReaderBuilder.Build().Create();

            var graphSon  = writer.WriteObject(point);
            var readPoint = reader.ToObject(JsonDocument.Parse(graphSon).RootElement);

            Assert.Equal(point, readPoint);
        }
        public void SerializeAndDeserialize_ValidRelationIdentifier_SameRelationIdentifier()
        {
            var relationIdentifier = new RelationIdentifier("4qp-360-7x1-3aw");
            var writer             = JanusGraphSONWriterBuilder.Build().Create();
            var reader             = JanusGraphSONReaderBuilder.Build().Create();

            var graphSon = writer.WriteObject(relationIdentifier);
            var readRelationIdentifier = reader.ToObject(JsonDocument.Parse(graphSon).RootElement);

            Assert.Equal(relationIdentifier, readRelationIdentifier);
        }
        public void RegisterDeserializer_CustomDeserializerForGivenType_DeserializerRegistered(string graphSONType,
                                                                                               object deserializationResult)
        {
            var customDeserializer = new DeserializerFake {
                DeserializationResult = deserializationResult
            };
            var graphSon = "{\"@type\":\"" + graphSONType + "\",\"@value\":0}";

            var reader = JanusGraphSONReaderBuilder.Build().RegisterDeserializer(graphSONType, customDeserializer).Create();

            Assert.Equal(deserializationResult, reader.ToObject(JsonDocument.Parse(graphSon).RootElement));
        }
        public void Read_GraphSonRelationIdentifier_ExpectedRelationIdentifier()
        {
            const string graphSon =
                "{\"@type\":\"janusgraph:RelationIdentifier\",\"@value\":{\"relationId\":\"3k1-360-6c5-39c\"}}";
            var reader = JanusGraphSONReaderBuilder.Build().Create();

            var readRelationIdentifier = reader.ToObject(JsonDocument.Parse(graphSon).RootElement);

            var expectedRelationIdentifier = new RelationIdentifier("3k1-360-6c5-39c");

            Assert.Equal(expectedRelationIdentifier, readRelationIdentifier);
        }
        public void Read_GraphSonPointWithGivenCoordinates_ExpectedPoint(double latitude, double longitude)
        {
            var graphSon = "{\"@type\":\"janusgraph:Geoshape\",\"@value\":{\"coordinates\":[" +
                           longitude.ToString(CultureInfo.InvariantCulture) + "," +
                           latitude.ToString(CultureInfo.InvariantCulture) + "]}}";
            var reader = JanusGraphSONReaderBuilder.Build().Create();

            var readPoint = reader.ToObject(JToken.Parse(graphSon));

            var expectedPoint = Geoshape.Point(latitude, longitude);

            Assert.Equal(expectedPoint, readPoint);
        }