Пример #1
0
        public void ShouldSerializeSubgraphStrategyWithoutValues(int version)
        {
            var subgraphStrategy = new SubgraphStrategy();
            var writer           = CreateGraphSONWriter(version);

            var graphSon = writer.WriteObject(subgraphStrategy);

            const string expected = "{\"@type\":\"g:SubgraphStrategy\",\"@value\":{}}";

            Assert.Equal(expected, graphSon);
        }
Пример #2
0
        public void ShouldDeserializeSubgraphStrategyWithVertexCriterion(int version)
        {
            var vertexCriterionBytecode = new Bytecode();

            vertexCriterionBytecode.AddStep("has", "name", "marko");
            var vertexCriterion  = new TestTraversal(vertexCriterionBytecode);
            var subgraphStrategy = new SubgraphStrategy(vertexCriterion);
            var writer           = CreateGraphSONWriter(version);

            var graphSon = writer.WriteObject(subgraphStrategy);

            const string expected =
                "{\"@type\":\"g:SubgraphStrategy\",\"@value\":{\"vertices\":{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"has\",\"name\",\"marko\"]]}}}}";

            Assert.Equal(expected, graphSon);
        }
Пример #3
0
        public void TraversalWithStrategies_StrategyWithTraversalInConfig_IncludeTraversalInInConfigInBytecode()
        {
            var g = AnonymousTraversalSource.Traversal();

            var bytecode = g.WithStrategies(new SubgraphStrategy(__.Has("name", "marko"))).Bytecode;

            Assert.Single(bytecode.SourceInstructions);
            Assert.Single(bytecode.SourceInstructions[0].Arguments);
            Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName);
            Assert.Equal(new SubgraphStrategy(), bytecode.SourceInstructions[0].Arguments[0]);
            SubgraphStrategy strategy = bytecode.SourceInstructions[0].Arguments[0];

            Assert.Single(strategy.Configuration);
            Assert.Equal(typeof(GraphTraversal <object, object>), strategy.Configuration["vertices"].GetType());
            ITraversal traversal = strategy.Configuration["vertices"];

            Assert.Equal("has", traversal.Bytecode.StepInstructions[0].OperatorName);
            Assert.Equal(new List <string> {
                "name", "marko"
            }, traversal.Bytecode.StepInstructions[0].Arguments);
        }
        public void TraversalWithStrategies_StrategyWithTraversalInConfig_IncludeTraversalInInConfigInBytecode()
        {
            var graph = new Graph();
            var g     = graph.Traversal();

            var bytecode = g.WithStrategies(new SubgraphStrategy(__.Has("name", "marko"))).Bytecode;

            Assert.Equal(1, bytecode.SourceInstructions.Count);
            Assert.Equal(1, bytecode.SourceInstructions[0].Arguments.Length);
            Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName);
            Assert.Equal(new SubgraphStrategy(), bytecode.SourceInstructions[0].Arguments[0]);
            SubgraphStrategy strategy = bytecode.SourceInstructions[0].Arguments[0];

            Assert.Equal(1, strategy.Configuration.Count);
            Assert.Equal(typeof(GraphTraversal), strategy.Configuration["vertices"].GetType());
            GraphTraversal traversal = strategy.Configuration["vertices"];

            Assert.Equal("has", traversal.Bytecode.StepInstructions[0].OperatorName);
            Assert.Equal(new List <string> {
                "name", "marko"
            }, traversal.Bytecode.StepInstructions[0].Arguments);
        }
Пример #5
0
 public static GraphTraversalSource SubG(SubgraphStrategy strategy) => G().WithStrategies(strategy);