|
1 | | -using System; |
2 | | -using System.Collections.Generic; |
3 | | -using System.Linq; |
4 | | -using System.Text; |
5 | | -using NUnit.Framework; |
6 | | -using Newtonsoft.Json; |
7 | | -using Newtonsoft.Json.Linq; |
8 | | - |
9 | | -using Nest; |
10 | | -using Newtonsoft.Json.Converters; |
11 | | -using Nest.Resolvers.Converters; |
12 | | -using Nest.Tests.MockData.Domain; |
13 | | -using FluentAssertions; |
14 | | -namespace Nest.Tests.Integration.Core.Get |
15 | | -{ |
16 | | - [TestFixture] |
17 | | - public class GetFullTests : CleanStateIntegrationTests |
18 | | - { |
19 | | - private void DefaultAssertations(IGetResponse<ElasticSearchProject> result) |
20 | | - { |
21 | | - result.IsValid.Should().BeTrue(); |
22 | | - result.Id.Should().Be("1"); |
23 | | - result.Index.Should().Be("nest_test_data"); |
24 | | - result.Type.Should().Be("elasticsearchprojects"); |
25 | | - result.Version.Should().Be("1"); |
26 | | - } |
27 | | - |
28 | | - [Test] |
29 | | - public void GetSimple() |
30 | | - { |
31 | | - var result = this._client.GetFull<ElasticSearchProject>(1); |
32 | | - this.DefaultAssertations(result); |
33 | | - |
34 | | - |
35 | | - } |
36 | | - [Test] |
37 | | - public void GetWithPathInfo() |
38 | | - { |
39 | | - var result = this._client.GetFull<ElasticSearchProject>("nest_test_data", "elasticsearchprojects", 1); |
40 | | - this.DefaultAssertations(result); |
41 | | - } |
42 | | - |
43 | | - [Test] |
44 | | - public void GetUsingDescriptorWithTypeAndFields() |
45 | | - { |
46 | | - var result = this._client.GetFull<ElasticSearchProject>(g => g |
47 | | - .Index("nest_test_data") |
48 | | - .Type("elasticsearchprojects") |
49 | | - .Id(1) |
50 | | - .Fields(p=>p.Content, p=>p.Name, p=>p.Id, p=>p.DoubleValue) |
51 | | - ); |
52 | | - this.DefaultAssertations(result); |
53 | | - |
54 | | - result.Source.Should().BeNull(); |
55 | | - result.Fields.Should().NotBeNull(); |
56 | | - result.Fields.FieldValues.Should().NotBeNull().And.HaveCount(4); |
57 | | - result.Fields.FieldValue<string>(p => p.Name).Should().Be("pyelasticsearch"); |
58 | | - result.Fields.FieldValue<int>(p => p.Id).Should().Be(1); |
59 | | - result.Fields.FieldValue<double>(p => p.DoubleValue).Should().BeApproximately(31.931359384177D, 0.00000001D); |
60 | | - |
61 | | - } |
62 | | - } |
63 | | -} |
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
| 5 | +using NUnit.Framework; |
| 6 | +using Newtonsoft.Json; |
| 7 | +using Newtonsoft.Json.Linq; |
| 8 | + |
| 9 | +using Nest; |
| 10 | +using Newtonsoft.Json.Converters; |
| 11 | +using Nest.Resolvers.Converters; |
| 12 | +using Nest.Tests.MockData.Domain; |
| 13 | +using FluentAssertions; |
| 14 | +namespace Nest.Tests.Integration.Core.Get |
| 15 | +{ |
| 16 | + [TestFixture] |
| 17 | + public class GetFullTests : CleanStateIntegrationTests |
| 18 | + { |
| 19 | + private void DefaultAssertations(IGetResponse<ElasticSearchProject> result) |
| 20 | + { |
| 21 | + result.IsValid.Should().BeTrue(); |
| 22 | + result.Id.Should().Be("1"); |
| 23 | + result.Index.Should().Be("nest_test_data"); |
| 24 | + result.Type.Should().Be("elasticsearchprojects"); |
| 25 | + result.Version.Should().Be("1"); |
| 26 | + result.Exists.Should().BeTrue(); |
| 27 | + } |
| 28 | + |
| 29 | + [Test] |
| 30 | + public void GetSimple() |
| 31 | + { |
| 32 | + var result = this._client.GetFull<ElasticSearchProject>(1); |
| 33 | + this.DefaultAssertations(result); |
| 34 | + |
| 35 | + |
| 36 | + } |
| 37 | + [Test] |
| 38 | + public void GetWithPathInfo() |
| 39 | + { |
| 40 | + var result = this._client.GetFull<ElasticSearchProject>("nest_test_data", "elasticsearchprojects", 1); |
| 41 | + this.DefaultAssertations(result); |
| 42 | + } |
| 43 | + |
| 44 | + [Test] |
| 45 | + public void GetUsingDescriptorWithTypeAndFields() |
| 46 | + { |
| 47 | + var result = this._client.GetFull<ElasticSearchProject>(g => g |
| 48 | + .Index("nest_test_data") |
| 49 | + .Type("elasticsearchprojects") |
| 50 | + .Id(1) |
| 51 | + .Fields(p=>p.Content, p=>p.Name, p=>p.Id, p=>p.DoubleValue) |
| 52 | + ); |
| 53 | + this.DefaultAssertations(result); |
| 54 | + |
| 55 | + result.Source.Should().BeNull(); |
| 56 | + result.Fields.Should().NotBeNull(); |
| 57 | + result.Fields.FieldValues.Should().NotBeNull().And.HaveCount(4); |
| 58 | + result.Fields.FieldValue<string>(p => p.Name).Should().Be("pyelasticsearch"); |
| 59 | + result.Fields.FieldValue<int>(p => p.Id).Should().Be(1); |
| 60 | + result.Fields.FieldValue<double>(p => p.DoubleValue).Should().BeApproximately(31.931359384177D, 0.00000001D); |
| 61 | + |
| 62 | + } |
| 63 | + |
| 64 | + [Test] |
| 65 | + public void GetMissing() |
| 66 | + { |
| 67 | + int doesNotExistId = 1234567; |
| 68 | + var result = this._client.GetFull<ElasticSearchProject>(doesNotExistId); |
| 69 | + result.Exists.Should().BeFalse(); |
| 70 | + } |
| 71 | + } |
| 72 | +} |
0 commit comments