|
| 1 | +using Elasticsearch.Net; |
| 2 | +using FluentAssertions; |
| 3 | +using Nest; |
| 4 | +using System; |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.Linq; |
| 7 | +using System.Text; |
| 8 | +using System.Threading.Tasks; |
| 9 | +using Tests.Framework; |
| 10 | + |
| 11 | +namespace Tests.ClientConcepts.LowLevel |
| 12 | +{ |
| 13 | + public class DirectStreaming |
| 14 | + { |
| 15 | + [U] |
| 16 | + public void DisableDirectStreamingOnError() |
| 17 | + { |
| 18 | + Action<IResponse> assert = r => |
| 19 | + { |
| 20 | + r.ApiCall.Should().NotBeNull(); |
| 21 | + r.ApiCall.RequestBodyInBytes.Should().NotBeNull(); |
| 22 | + r.ApiCall.ResponseBodyInBytes.Should().NotBeNull(); |
| 23 | + }; |
| 24 | + |
| 25 | + var client = TestClient.GetFixedReturnClient(new { }, 404, s => s.DisableDirectStreaming()); |
| 26 | + var response = client.Search<object>(s => s); |
| 27 | + assert(response); |
| 28 | + response = client.SearchAsync<object>(s => s).Result; |
| 29 | + assert(response); |
| 30 | + } |
| 31 | + |
| 32 | + [U] |
| 33 | + public void EnableDirectStreamingOnError() |
| 34 | + { |
| 35 | + Action<IResponse> assert = r => |
| 36 | + { |
| 37 | + r.ApiCall.Should().NotBeNull(); |
| 38 | + r.ApiCall.RequestBodyInBytes.Should().BeNull(); |
| 39 | + r.ApiCall.ResponseBodyInBytes.Should().BeNull(); |
| 40 | + }; |
| 41 | + |
| 42 | + var client = TestClient.GetFixedReturnClient(new { }, 404); |
| 43 | + var response = client.Search<object>(s => s); |
| 44 | + assert(response); |
| 45 | + response = client.SearchAsync<object>(s => s).Result; |
| 46 | + assert(response); |
| 47 | + } |
| 48 | + |
| 49 | + [U] |
| 50 | + public void DisableDirectStreamingOnSuccess() |
| 51 | + { |
| 52 | + Action<IResponse> assert = r => |
| 53 | + { |
| 54 | + r.ApiCall.Should().NotBeNull(); |
| 55 | + r.ApiCall.RequestBodyInBytes.Should().NotBeNull(); |
| 56 | + r.ApiCall.ResponseBodyInBytes.Should().NotBeNull(); |
| 57 | + }; |
| 58 | + |
| 59 | + var client = TestClient.GetFixedReturnClient(new { }, 200, s => s.DisableDirectStreaming()); |
| 60 | + var response = client.Search<object>(s => s); |
| 61 | + assert(response); |
| 62 | + response = client.SearchAsync<object>(s => s).Result; |
| 63 | + assert(response); |
| 64 | + } |
| 65 | + |
| 66 | + [U] |
| 67 | + public void EnableDirectStreamingOnSuccess() |
| 68 | + { |
| 69 | + Action<IResponse> assert = r => |
| 70 | + { |
| 71 | + r.ApiCall.Should().NotBeNull(); |
| 72 | + r.ApiCall.RequestBodyInBytes.Should().BeNull(); |
| 73 | + r.ApiCall.ResponseBodyInBytes.Should().BeNull(); |
| 74 | + }; |
| 75 | + |
| 76 | + var client = TestClient.GetFixedReturnClient(new { }); |
| 77 | + var response = client.Search<object>(s => s); |
| 78 | + assert(response); |
| 79 | + response = client.SearchAsync<object>(s => s).Result; |
| 80 | + assert(response); |
| 81 | + } |
| 82 | + } |
| 83 | +} |
0 commit comments