本文整理汇总了C#中Couchbase.N1QL.QueryRequest.GetFormValues方法的典型用法代码示例。如果您正苦于以下问题:C# QueryRequest.GetFormValues方法的具体用法?C# QueryRequest.GetFormValues怎么用?C# QueryRequest.GetFormValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Couchbase.N1QL.QueryRequest
的用法示例。
在下文中一共展示了QueryRequest.GetFormValues方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Statement
public void Test_Statement()
{
var query = new QueryRequest().
BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
Statement("SELECT * FROM default");
var values = query.GetFormValues();
Assert.AreEqual("SELECT * FROM default", values["statement"]);
}
示例2: Test_Positional_Parameters
public void Test_Positional_Parameters()
{
var query = new QueryRequest().
BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
Statement("SELECT * FROM default WHERE type=$1").
AddPositionalParameter("dog");
var values = query.GetFormValues();
Assert.AreEqual("SELECT * FROM default WHERE type=$1", values["statement"]);
Assert.AreEqual(new[] {"dog"}, values["args"]);
}
示例3: Test_Statement_ClientContextId_Pretty
public void Test_Statement_ClientContextId_Pretty()
{
var query = new QueryRequest().
BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
Statement("SELECT * FROM default").
ClientContextId("somecontextlessthanorequalto64chars").
Pretty(true);
var values = query.GetFormValues();
Assert.AreEqual(true, values["pretty"]);
}
示例4: Test_Statement_ClientContextId
public void Test_Statement_ClientContextId()
{
var query = new QueryRequest().
BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
Statement("SELECT * FROM default").
ClientContextId("somecontextlessthanorequalto64chars");
var values = query.GetFormValues();
string contextid = values["client_context_id"].ToString().Split(new String[] {"::"}, System.StringSplitOptions.None)[0];
Assert.AreEqual("somecontextlessthanorequalto64chars", contextid);
}
示例5: GetFormValues_MultipleTokensSameVBucketId_HighestSequenceNumberIsUsed2
public void GetFormValues_MultipleTokensSameVBucketId_HighestSequenceNumberIsUsed2()
{
var document1 = new Mock<IDocument<dynamic>>();
document1.Setup(x => x.Token).Returns(new MutationToken("bucket1_name", 102, 22, 9999));
var document2 = new Mock<IDocument<dynamic>>();
document2.Setup(x => x.Token).Returns(new MutationToken("bucket1_name", 102, 11, 8332));
var document3 = new Mock<IDocument<dynamic>>();
document3.Setup(x => x.Token).Returns(new MutationToken("bucket2_name", 133, 23, 333));
var queryRequest = new QueryRequest("SELECT * FROM `bucket1_name`;").
ConsistentWith(MutationState.From(document1.Object, document2.Object, document3.Object)).
#pragma warning disable 618
ScanConsistency(ScanConsistency.AtPlus);
#pragma warning restore 618
var actual = queryRequest.GetFormValues()["scan_vectors"];
var expected = "{\"bucket1_name\":{\"102\":[9999,\"22\"]},\"bucket2_name\":{\"133\":[333,\"23\"]}}";
Assert.AreEqual(expected, JsonConvert.SerializeObject(actual));
}
示例6: GetFormValues_WhenScanConsistenyIsAtPlus_ScanVectorsIsAddedToFormValues
public void GetFormValues_WhenScanConsistenyIsAtPlus_ScanVectorsIsAddedToFormValues()
{
var document1 = new Mock<IDocument<dynamic>>();
document1.Setup(x => x.Token).Returns(new MutationToken("bucket1_name", 102, 22, 8282));
var document2 = new Mock<IDocument<dynamic>>();
document2.Setup(x => x.Token).Returns(new MutationToken("bucket1_name", 123, 11, 8332));
var document3 = new Mock<IDocument<dynamic>>();
document3.Setup(x => x.Token).Returns(new MutationToken("bucket2_name", 133, 23, 333));
var queryRequest = new QueryRequest("SELECT * FROM `bucket1_name`;").
ConsistentWith(MutationState.From(document1.Object, document2.Object, document3.Object)).
#pragma warning disable 618
ScanConsistency(ScanConsistency.AtPlus);
#pragma warning restore 618
var actual = queryRequest.GetFormValues()["scan_vectors"];
var expected = "{\"bucket1_name\":{\"102\":[8282,\"22\"],\"123\":[8332,\"11\"]},\"bucket2_name\":{\"133\":[333,\"23\"]}}";
Assert.AreEqual(expected, JsonConvert.SerializeObject(actual));
}
示例7: When_MaxServerParallism_Is_Set_Request_Has_It
public void When_MaxServerParallism_Is_Set_Request_Has_It()
{
var queryRequest = new QueryRequest("SELECT * FROM default;");
queryRequest.MaxServerParallelism(4);
var query = queryRequest.GetFormValues();
Assert.AreEqual(4.ToString(), query["max_parallelism"]);
}
示例8: When_ScanWait_Is_Set_Request_Has_The_Value
public void When_ScanWait_Is_Set_Request_Has_The_Value()
{
var queryRequest = new QueryRequest("SELECT * FROM default;");
queryRequest.ScanWait(TimeSpan.FromSeconds(10));
var query = queryRequest.GetFormValues();
Assert.AreEqual("10000ms", query["scan_wait"]);
}
示例9: When_Timeout_Is_Not_Set_QueryString_Values_Use_Timeout_Default
public void When_Timeout_Is_Not_Set_QueryString_Values_Use_Timeout_Default()
{
var query = new QueryRequest()
.BaseUri(new Uri(string.Format("http://{0}:8093/query", _server)))
.Statement("SELECT * from Who");
var queryStringValues = query.GetFormValues();
Assert.AreEqual(queryStringValues["timeout"], "75000ms");
}
示例10: Test_Named_Parameters_Two_Arguments
public void Test_Named_Parameters_Two_Arguments()
{
var query = new QueryRequest().
BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
Statement("SELECT * FROM default WHERE type=$canine OR type=$feline").
AddNamedParameter("canine", "dog").
AddNamedParameter("feline", "cat");
var values = query.GetFormValues();
Assert.AreEqual("SELECT * FROM default WHERE type=$canine OR type=$feline", values["statement"]);
Assert.AreEqual("dog", values["$canine"]);
Assert.AreEqual("cat", values["$feline"]);
}
示例11: When_Timeout_Is_Not_Set_Default_To_75000ms
public void When_Timeout_Is_Not_Set_Default_To_75000ms()
{
var query = new QueryRequest()
.BaseUri(new Uri(string.Format("http://{0}:8093/query", _server)))
.Statement("SELECT * FROM `beer-sample`");
var values = query.GetFormValues();
Assert.AreEqual("SELECT * FROM `beer-sample`", values["statement"]);
Assert.AreEqual("75000ms", values["timeout"]);
}
示例12: When_Timeout_Set_Query_Contains_Milliseconds_With_Unit
public void When_Timeout_Set_Query_Contains_Milliseconds_With_Unit()
{
var query = new QueryRequest()
.BaseUri(new Uri(string.Format("http://{0}:8093/query", _server)))
.Statement("SELECT * FROM `beer-sample`")
.Timeout(new TimeSpan(0, 0, 0, 0, 5));
var values = query.GetFormValues();
Assert.AreEqual("SELECT * FROM `beer-sample`", values["statement"]);
Assert.AreEqual("5ms", values["timeout"]);
}
示例13: When_isAdmin_Is_False_Credentials_Contains_local
public void When_isAdmin_Is_False_Credentials_Contains_local()
{
var query = new QueryRequest().
BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
Statement("SELECT * FROM authenticated").
AddCredentials("authenticated", "secret", false);
var values = query.GetFormValues();
Assert.AreEqual("SELECT * FROM authenticated", values["statement"]);
Assert.AreEqual("{ user = local:authenticated, pass = secret }",
((List<Object>)values["creds"]).ElementAt(0).ToString());
}
示例14: MutationState_WhenScanConsistencyIsNotAtPlus_ThrowsArgumentException
public void MutationState_WhenScanConsistencyIsNotAtPlus_ThrowsArgumentException()
{
var document1 = new Mock<IDocument<dynamic>>();
document1.Setup(x => x.Token).Returns(new MutationToken("bucket1_name", 102, 22, 8282));
var document2 = new Mock<IDocument<dynamic>>();
document2.Setup(x => x.Token).Returns(new MutationToken("bucket1_name", 123, 11, 8332));
var document3 = new Mock<IDocument<dynamic>>();
document3.Setup(x => x.Token).Returns(new MutationToken("bucket2_name", 133, 23, 333));
var queryRequest = new QueryRequest("SELECT * FROM `bucket1_name`;").
ConsistentWith(MutationState.From(document1.Object, document2.Object, document3.Object)).
ScanConsistency(ScanConsistency.NotBounded);
Assert.Throws<ArgumentException>(() => queryRequest.GetFormValues());
}