private static Bytecode CreateGraphOp(string name, object value) { var bytecode = new Bytecode(); bytecode.AddSource(name, value); return(bytecode); }
public void ShouldUseBindingsInsideArrayInSourceArgument() { var bytecode = new Bytecode(); var b = Bindings.Instance; bytecode.AddSource("someSource", "test", new[] { b.Of("arrayVariable", "arrayValue") }); Assert.Equal(new Binding("arrayVariable", "arrayValue"), bytecode.SourceInstructions[0].Arguments[1]); }
public void ShouldUseBingingsForSimpleValueInSourceArgument() { var bytecode = new Bytecode(); var bindings = Bindings.Instance; bytecode.AddSource("hasLabel", bindings.Of("label", "testvalue")); Assert.Equal(new Binding("label", "testvalue"), bytecode.SourceInstructions[0].Arguments[0]); }
public void ShouldUseBindingsInsideHashSetInSourceArgument() { var bytecode = new Bytecode(); var b = Bindings.Instance; bytecode.AddSource("someSource", new HashSet <string> { "test", b.Of("setVariable", "setValue") }); var arg = bytecode.SourceInstructions[0].Arguments[0] as ISet <object>; Assert.Equal(new Binding("setVariable", "setValue"), arg.ToList()[1]); }
public void ShouldUseBindingsInsideListInSourceArgument() { var bytecode = new Bytecode(); var b = Bindings.Instance; bytecode.AddSource("someSource", new List <string> { "test", b.Of("listVariable", "listValue") }); var arg = bytecode.SourceInstructions[0].Arguments[0] as IList; Assert.Equal(new Binding("listVariable", "listValue"), arg[1]); }
public void ShouldUseBindingsInsideDictionaryValuesInSourceArgument() { var bytecode = new Bytecode(); var b = Bindings.Instance; bytecode.AddSource("someSource", new Dictionary <string, object> { { "someKey", b.Of("valVariable", "valValue") } }); var arg = bytecode.SourceInstructions[0].Arguments[0] as IDictionary; Assert.Equal(new Binding("valVariable", "valValue"), arg["someKey"]); }
public void ShouldUseBindingsInsideDictionaryKeysInSourceArgument() { var bytecode = new Bytecode(); var b = Bindings.Instance; bytecode.AddSource("someSource", new Dictionary <string, object> { { b.Of("keyVariable", "keyValue"), 1234 } }); var arg = bytecode.SourceInstructions[0].Arguments[0]; var binding = ((Dictionary <object, object>)arg).Keys.First() as Binding; Assert.Equal(new Binding("keyVariable", "keyValue"), binding); }
public void ShouldSerializeBytecodeWithSourcesStep(int version) { var bytecode = new Bytecode(); bytecode.AddSource("withSideEffect", "a", "josh"); bytecode.AddStep("V", 1); bytecode.AddStep("values", "name"); bytecode.AddStep("where", new TraversalPredicate("within", "a")); var graphsonWriter = CreateGraphSONWriter(version); var graphSON = graphsonWriter.WriteObject(bytecode); var expectedGraphSon = "{\"@type\":\"g:Bytecode\",\"@value\":{\"source\":[[\"withSideEffect\",\"a\",\"josh\"]],\"step\":[[\"V\",{\"@type\":\"g:Int32\",\"@value\":1}],[\"values\",\"name\"],[\"where\",{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"within\",\"value\":\"a\"}}]]}}"; Assert.Equal(expectedGraphSon, graphSON); }