Skip to content

Commit 002cfa4

Browse files
committed
added some string and anon C# object body tests to the raw client
1 parent 8902e22 commit 002cfa4

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

Diff for: src/Nest.Tests.Integration/ConnectionTests.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,13 @@ public void ConnectUsingRawClient()
118118
[Test]
119119
public void ConnectUsingRawClientComplexCall()
120120
{
121-
var result = this._client.Raw.ClusterHealthGet(s=>s.Level(LevelOptions.Indices).Local(true));
121+
var result = this._client.Raw.ClusterHealthGet(s=>s
122+
.Level(LevelOptions.Indices)
123+
.Local(true)
124+
.WaitForActiveShards(12)
125+
);
122126
Assert.IsTrue(result.Success);
123-
StringAssert.EndsWith(":9200/_cluster/health?level=indices&local=true&pretty=true", result.RequestUrl);
127+
StringAssert.EndsWith(":9200/_cluster/health?level=indices&local=true&wait_for_active_shards=12&pretty=true", result.RequestUrl);
124128

125129
}
126130
}

Diff for: src/Nest.Tests.Unit/Core/Domain/Connection/ConnectionTests.cs

+28-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public HttpWebRequest GetConnection(string path, string method)
1818
}
1919

2020
[TestFixture]
21-
public class ConnectionTests
21+
public class ConnectionTests : BaseJsonTests
2222
{
2323
[Test]
2424
public void CanCreateConnectionWithCustomQueryStringParameters()
@@ -51,5 +51,32 @@ public void CanCreateConnectionWithPathAndCustomQueryStringParameters()
5151
// Assert
5252
Assert.AreEqual(req.Address.ToString(), "http://localhost:9000/index/?authToken=ABCDEFGHIJK");
5353
}
54+
55+
56+
[Test]
57+
public void SendStringAsJsonBody()
58+
{
59+
var jsonAsString = "{ \"json_as_a_string\" : true}";
60+
var result = this._client.Raw.BulkPost(jsonAsString, qs => qs
61+
.Replication(ReplicationOptions.Async)
62+
.Refresh(true)
63+
);
64+
StringAssert.EndsWith(":9200/_bulk?replication=async&refresh=true", result.RequestUrl);
65+
Assert.AreEqual(jsonAsString, result.Request);
66+
}
67+
68+
[Test]
69+
public void SendAnonymousObjectAsJsonBody()
70+
{
71+
var jsonAsString = "{\r\n \"json_as_a_string\": true\r\n}";
72+
var result = this._client.Raw.BulkPost(
73+
new { json_as_a_string = true }
74+
, qs => qs
75+
.Replication(ReplicationOptions.Async)
76+
.Refresh(true)
77+
);
78+
StringAssert.EndsWith(":9200/_bulk?replication=async&refresh=true", result.RequestUrl);
79+
Assert.AreEqual(jsonAsString, result.Request);
80+
}
5481
}
5582
}

0 commit comments

Comments
 (0)