public void ExecuteAndGetResultSteps() { const long vertId = 987654; const string queryName = "Trav-vertices-withid"; string pathText = "Vertices/WithId(" + vertId + ")"; const string expectScript = "g.V.has(_P, Tokens.T.eq, _P)[0..99];"; var expectValues = new List <object> { DbName.Vert.Vertex.VertexId, vertId }; var dto = new DataDto(); dto.Id = "A"; dto.VertexType = VertexType.Id.Vertex; dto.Properties = new Dictionary <string, string>(); dto.Properties.Add(DbName.Vert.Vertex.VertexId, vertId + ""); dto.Properties.Add(DbName.Vert.Vertex.VertexType, (byte)dto.VertexType + ""); dto.Properties.Add(DbName.Vert.Vertex.Timestamp, "1236546735"); var vertDtos = new List <IDataDto> { dto }; var mockRes = new Mock <IDataResult>(MockBehavior.Strict); mockRes.Setup(x => x.ToDtoList()).Returns(vertDtos); vMockData .Setup(x => x.Execute(It.IsAny <WeaverQuery>(), queryName)) .Returns(mockRes.Object) .Callback((IWeaverQuery q, string name) => TestUtil.CheckWeaverScript(q, expectScript, "_P", expectValues)); IList <FabElement> result = vOper.Execute(vMockOpCtx.Object, pathText); Assert.NotNull(result, "Result should be filled."); Assert.AreEqual(1, result.Count, "Incorrect result count."); Assert.AreEqual(typeof(FabVertex), result[0].GetType(), "Incorrect result[0] type."); FabVertex v = (FabVertex)result[0]; Assert.AreEqual(vertId, v.Id, "Incorrect result[0].Id."); //// IList <FabTravStep> resultSteps = vOper.GetResultSteps(); Assert.NotNull(resultSteps, "Result steps should be filled."); Assert.Less(0, resultSteps.Count, "Incorrect result steps count."); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private static IApiResponse TravResp(IApiRequest pApiReq) { FabTravStep[] steps = null; Func <IList <FabElement> > getResp = (() => { string path = pApiReq.Path; path = path.Substring(path.ToLower().IndexOf("trav/") + 5); //remove "/Trav/" var op = new TraversalOperation(); IList <FabElement> result = op.Execute(pApiReq.OpCtx, path); steps = op.GetResultSteps().ToArray(); return(result); }); var exec = new FabResponseExecutor <FabElement>(pApiReq, getResp); exec.NewFabResponse = (() => new FabTravResponse <FabElement> { Steps = steps }); return(exec.Execute()); }