/// <summary> /// Extracts criterion from a "where" filter /// </summary> /// <param name="args">The arguments.</param> /// <param name="start">The start.</param> /// <returns>SearchCriterionDto.</returns> /// <exception cref="Exception">asabab</exception> private SearchCriterionDto ExtractWhere(string[] args, int start) { if (args == null || !args.Any() || start > args.Length) { return(null); } var property = args[start]; switch (property) { case "rax": case "rbx": // todo: add the rest of the registers var newArgs = args.Skip(start).TakeWhile(s => !Separators.Contains(s)).ToArray(); var term = new TerminalSearchCriterionDto { Type = "register", Args = newArgs }; if (start + newArgs.Length >= args.Length) { return(term); } return(ExtractCompound(args, start + newArgs.Length, term)); default: throw new Exception("asabab"); } }
/// <summary> /// Visits the specified search criterion dto. /// </summary> /// <param name="searchCriterionDto">The search criterion dto.</param> /// <returns>System.Object.</returns> public object Visit(TerminalSearchCriterionDto searchCriterionDto) { var o = new JObject { { "Type", searchCriterionDto.Type }, { "Args", new JArray(searchCriterionDto.Args) } }; return(o); }
public void Search_For_Frames() { var crit = new TerminalSearchCriterionDto(); var frames = new[] { new Frame() { Id = Guid.NewGuid(), }, }; // arrange var httpBuilder = new HttpFacadeBuilder(); httpBuilder.WithPostAsync(new HttpResponseMessage(HttpStatusCode.OK)); httpBuilder.WithPostJsonAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(frames))) }); var settings = new Settings { ServerUrl = "https://some.server.net", ProjectName = "testing" }; var serverClient = new ServerClient { HttpFacade = httpBuilder.Build(), Settings = settings }; var headers = new HttpHeaders(); headers.Add("X-Project-Name", "testing"); var response = serverClient.SearchFrames(crit); response.SequenceEqual(frames).Should().BeTrue(); httpBuilder.Mock.Verify( facade => facade.PostJsonAsync(new Uri("https://some.server.net/api/search/frame"), crit, headers), Times.Once); }