public void TokenizesQueryWithExceptions() { Assert.Throws <Exception>(() => UrlQueryParser.TokenizeQueryTerms("[Foo]:BETWEEN{18,70,80}")); Assert.Throws <Exception>(() => UrlQueryParser.TokenizeQueryTerms("[Foo]:NOTBETWEEN{18,70,80}")); Assert.Throws <Exception>(() => UrlQueryParser.TokenizeQueryTerms("[Foo]:IN{}")); Assert.Throws <Exception>(() => UrlQueryParser.TokenizeQueryTerms("[Foo]:NOTIN{}")); }
public static ResponseInfo <TReturn> Delete <TReturn>(string url) { var items = UrlQueryParser.UrlToData(url).Item2; SortedList <string, object> list = new SortedList <string, object>(); if (items != null) { foreach (var c in items) { list.Add(c.Key, c.Value); } } var a = SignBuilder.BuildSignList(list, "", ""); if (url.Contains('?')) { url += "&reqTime=" + a.ReqTime + "&sign=" + a.Sign; } else { url += "?reqTime=" + a.ReqTime + "&sign=" + a.Sign; } HttpClient httpClient = new HttpClient(); Task <HttpResponseMessage> response = httpClient.DeleteAsync(url); var result = ConvertToResult <TReturn>(response); return(result); }
private void AssertValidQueryTerm(string query, string resultSqlQuery, string resultSqlParams, bool useExtendedTypes = false) { var(sqlQuery, sqlParams) = UrlQueryParser.ParseQuery(query, useExtendedTypes); Assert.Equal(resultSqlQuery, sqlQuery); Assert.Equal(resultSqlParams, JsonSerializer.Serialize(sqlParams)); }
public void TokenizesQueryWithExtendedTypes() { Assert.Equal(resQueryTokensEqNeIsNull, JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms(testQueryEqNeIsNull, true))); Assert.Equal(resQueryTokensGtLtIsNotNull, JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms(testQueryGtLtIsNotNull, true))); Assert.Equal(resQueryTokensGeLeLike, JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms(testQueryGeLeLike, true))); Assert.Equal(resQueryTokensBetweenNotIn, JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms(testQueryBetweenNotIn, true))); Assert.Equal(resQueryTokensNotBetweenIn, JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms(testQueryNotBetweenIn, true))); Assert.Equal(resTokensInfectedQuery, JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms(testInfectedQuery, true))); }
public void ParsesQuery() { AssertValidQueryTerm(testQueryEqNeIsNull, resSqlQueryEqNeIsNull, resSqlParamsEqNeIsNull); AssertValidQueryTerm(testQueryGtLtIsNotNull, testSqlQueryGtLtIsNotNull, resSqlParamsGtLtIsNotNull); AssertValidQueryTerm(testQueryGeLeLike, testSqlQueryGeLeLike, resSqlParamsGeLeLike); AssertValidQueryTerm(testQueryBetweenNotIn, testSqlQueryBetweenNotIn, testSqlParamsBetweenNotIn); AssertValidQueryTerm(testQueryNotBetweenIn, testSqlQueryNotBetweenIn, testSqlParamsNotBetweenIn); AssertValidQueryTerm(testInfectedQuery, testSqlInfectedQuery, testSqlParamsInfectedQuery); Assert.Equal(Tuple.Create(string.Empty, new object[0]), UrlQueryParser.ParseQuery("[Foo] {'Bar'}")); }
public void ParsesTermOperator() { Assert.Equal("=", UrlQueryParser.ParseTermOperator("EQ")); Assert.Equal("<>", UrlQueryParser.ParseTermOperator("NE")); Assert.Equal(">", UrlQueryParser.ParseTermOperator("GT")); Assert.Equal(">=", UrlQueryParser.ParseTermOperator("GE")); Assert.Equal("<", UrlQueryParser.ParseTermOperator("LT")); Assert.Equal("<=", UrlQueryParser.ParseTermOperator("LE")); Assert.Equal("LIKE", UrlQueryParser.ParseTermOperator("LIKE")); Assert.Equal("NOT LIKE", UrlQueryParser.ParseTermOperator("NOTLIKE")); Assert.Equal("BETWEEN", UrlQueryParser.ParseTermOperator("BETWEEN")); Assert.Equal("NOT BETWEEN", UrlQueryParser.ParseTermOperator("NOTBETWEEN")); Assert.Equal("IN", UrlQueryParser.ParseTermOperator("IN")); Assert.Equal("NOT IN", UrlQueryParser.ParseTermOperator("NOTIN")); Assert.Equal("IS NULL", UrlQueryParser.ParseTermOperator("ISNULL")); Assert.Equal("IS NOT NULL", UrlQueryParser.ParseTermOperator("ISNOTNULL")); }
public void TokenizesQuery() { Assert.Equal(resQueryTokensEqNeIsNull, JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms(testQueryEqNeIsNull))); Assert.Equal(resQueryTokensGtLtIsNotNull, JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms(testQueryGtLtIsNotNull))); Assert.Equal(resQueryTokensGeLeLike, JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms(testQueryGeLeLike))); Assert.Equal(resQueryTokensBetweenNotIn, JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms(testQueryBetweenNotIn))); Assert.Equal(resQueryTokensNotBetweenIn, JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms(testQueryNotBetweenIn))); Assert.Equal(resTokensInfectedQuery, JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms(testInfectedQuery))); Assert.Equal(resQueryTokensEqNeIsNull, JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms(testQueryEqNeIsNull + " [Foo]"))); Assert.Equal(resQueryTokensGtLtIsNotNull, JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms(testQueryGtLtIsNotNull + " EQ{123}"))); Assert.Equal("{}", JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms("[Foo]"))); Assert.Equal("{}", JsonSerializer.Serialize(UrlQueryParser.TokenizeQueryTerms("EQ{123}"))); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // TODO: change this value to a cache size that is appropriate for your application rootFrame.CacheSize = 1; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // Removes the turnstile navigation for startup. if (rootFrame.ContentTransitions != null) { this.transitions = new TransitionCollection(); foreach (var c in rootFrame.ContentTransitions) { this.transitions.Add(c); } } rootFrame.ContentTransitions = null; rootFrame.Navigated += this.RootFrame_FirstNavigated; // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } if (!string.IsNullOrEmpty(e.Arguments)) { rootFrame.Navigate(typeof(MainPage), UrlQueryParser.ParseQueryString(e.Arguments)[Registration.PUSH_ID_KEY]); } // Ensure the current window is active Window.Current.Activate(); }
public void SanitizesQuery() { Assert.Equal(testSanitizedQuery, UrlQueryParser.SanitizeUrlQuery(testInfectedQuery)); }
public void ParsesOrder() { Assert.Equal(resSqlOrder, UrlQueryParser.ParseOrder(testOrder)); Assert.Equal(resSqlInfectedOrder, UrlQueryParser.ParseOrder(testInfectedOrder)); Assert.Equal(string.Empty, UrlQueryParser.ParseOrder("Foo, Bar")); }